-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 2.23 KB
/
dependabot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Dependabot
on:
push:
branches: [ dependabot/npm_and_yarn/** ]
jobs:
build:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
persist-credentials: false # minimize exposure
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '12'
- name: Autofix lockfile
run: |
# change directory
# assuming Angular commit style (build: bump XXX from AAA to BBB in YYY)
# use $8 for default commit message style (Bump XXX from AAA to BBB in YYY)
cd .`git log -1 --pretty=%s | awk '{ print $9 }'`
# restore yarn.lock from the previous commit
git checkout HEAD^ -- yarn.lock
# install yarn-plugin-deduplicate
yarn plugin import https://raw.githubusercontent.com/eps1lon/yarn-plugin-deduplicate/latest/bin/%40yarnpkg/plugin-deduplicate.js
# if package.json was not updated, upgrade the dependency
# assuming Angular commit style (build: bump XXX from ...)
# use $2 for default commit message style (Bump XXX from ...)
git diff --name-only HEAD^ HEAD | grep -q 'package.json' || yarn up `git log -1 --pretty=%s | awk '{ print $3 }'`
# restore package.json from the last commit
git checkout HEAD -- package.json
yarn install
# deduplicate lockfile
yarn deduplicate
env:
YARN_ENABLE_SCRIPTS: 0 # disable postinstall scripts
- name: Config Git
run: |
# use personal access token to allow triggering new workflow
BASIC_AUTH=$(echo -n "x-access-token:${{ secrets.GH_TOKEN }}" | base64)
echo "::add-mask::$BASIC_AUTH"
git config --global user.name '${{ github.event.commits[0].author.name }}'
git config --global user.email '${{ github.event.commits[0].author.email }}'
git config --local http.$GITHUB_SERVER_URL/.extraheader "AUTHORIZATION: basic $BASIC_AUTH"
- name: Commit changes
run: |
cd .`git log -1 --pretty=%s | awk '{ print $9 }'` # ditto
git add yarn.lock .yarn/cache .pnp.* # only add yarn.lock if not using zero-installs
git commit -m "Dependabot autofix"
git push