Skip to content

Commit 2a9779f

Browse files
committed
Add workflow to make dependabot commits compatible with Yarn v2
Adapted from dependabot/dependabot-core#1297 (comment)
1 parent 57372fc commit 2a9779f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/dependabot.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 2
15+
- name: Use Node.js 12.x
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: '12'
19+
20+
- name: Autofix lockfile
21+
run: |
22+
# restore yarn.lock from the previous commit
23+
git checkout HEAD^ -- yarn.lock
24+
25+
# if package.json was not updated, upgrade the dependency
26+
git diff --name-only HEAD^ HEAD | grep -q 'package.json' || yarn up `git log -1 --pretty=%s | awk '{ print $2 }'`
27+
28+
# restore package.json from the last commit
29+
git checkout HEAD -- package.json
30+
31+
yarn install
32+
33+
- name: Commit changes
34+
run: |
35+
git add yarn.lock
36+
git config --global user.name 'dependabot[bot]'
37+
git config --global user.email '49699333+dependabot[bot]@users.noreply.github.com'
38+
git commit --amend
39+
git push -f

0 commit comments

Comments
 (0)