File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Dependabot
2+
3+ on :
4+ push :
5+ branches : [ dependabot/npm_and_yarn/** ]
6+
7+ jobs :
8+ build :
9+ runs-on : ubuntu-latest
10+ if : github.actor == 'dependabot[bot]'
11+
12+ steps :
13+ - uses : actions/checkout@v2
14+ with :
15+ fetch-depth : 2
16+ persist-credentials : false # minimize exposure
17+ - name : Use Node.js 12.x
18+ uses : actions/setup-node@v1
19+ with :
20+ node-version : ' 12'
21+ - name : Autofix lockfile
22+ run : |
23+ # change directory
24+ cd .`git log -1 --pretty=%s | awk '{ print $9 }'`
25+
26+ # restore yarn.lock from the previous commit
27+ git checkout HEAD^ -- yarn.lock
28+
29+ # install yarn-plugin-deduplicate
30+ yarn plugin import https://raw.githubusercontent.com/eps1lon/yarn-plugin-deduplicate/latest/bin/%40yarnpkg/plugin-deduplicate.js
31+
32+ # if package.json was not updated, upgrade the dependency
33+ git diff --name-only HEAD^ HEAD | grep -q 'package.json' || yarn up `git log -1 --pretty=%s | awk '{ print $3 }'`
34+
35+ # restore package.json from the last commit
36+ git checkout HEAD -- package.json
37+
38+ yarn install
39+
40+ # deduplicate lockfile
41+ yarn deduplicate
42+ - name : Config Git
43+ run : |
44+ # use personal access token to allow triggering new workflow
45+ BASIC_AUTH=$(echo -n "x-access-token:${{ secrets.GH_TOKEN }}" | base64)
46+ echo "::add-mask::$BASIC_AUTH"
47+ git config --global user.name '${{ github.event.commits[0].author.name }}'
48+ git config --global user.email '${{ github.event.commits[0].author.email }}'
49+ git config --local http.$GITHUB_SERVER_URL/.extraheader "AUTHORIZATION: basic $BASIC_AUTH"
50+ - name : Commit changes
51+ run : |
52+ cd .`git log -1 --pretty=%s | awk '{ print $9 }'`
53+ git add yarn.lock
54+ git commit -m "Dependabot autofix"
55+ git push
You can’t perform that action at this time.
0 commit comments