22#
33# Automatically approve Dependabot pull requests and enable auto-merge.
44#
5- # Note: @dependabot generates Yarn v1 lockfiles despite this project using a different Yarn version.
6- # This breaks the project lockfile. A workaround has been implemented to autofix lockfiles and
7- # deduplicate dependencies. See https://github.com/dependabot/dependabot-core/issues/1297 to check
8- # if the workaround is safe to remove.
9- #
105# References:
116#
127# - https://cli.github.com/manual/gh_pr_merge
138# - https://cli.github.com/manual/gh_pr_review
149# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
1510# - https://docs.github.com/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
1611# - https://github.com/actions/checkout
17- # - https://github.com/actions/setup-node
18- # - https://github.com/crazy-max/ghaction-import-gpg
1912# - https://github.com/dependabot/fetch-metadata
2013# - https://github.com/hmarr/debug-action
2114
@@ -42,52 +35,13 @@ jobs:
4235 name : Checkout ${{ github.head_ref }}
4336 uses : actions/checkout@v3.0.2
4437 with :
45- persist-credentials : ${{ steps.metadata.outputs.package-ecosystem == 'npm_and_yarn' }}
4638 ref : ${{ github.head_ref }}
4739 token : ${{ env.GITHUB_TOKEN }}
48- - id : gpg-import
49- name : Import GPG key
50- if : steps.metadata.outputs.package-ecosystem == 'npm_and_yarn'
51- uses : crazy-max/ghaction-import-gpg@v5.1.0
52- with :
53- git_commit_gpgsign : true
54- git_config_global : true
55- git_user_signingkey : true
56- gpg_private_key : ${{ secrets.GPG_PRIVATE_KEY }}
57- # todo: remove when https://github.com/crazy-max/ghaction-import-gpg/issues/118 is resolved
58- - id : gpg-trust
59- name : Set trust on GPG key
60- if : steps.metadata.outputs.package-ecosystem == 'npm_and_yarn'
61- run : |
62- gpg --no-tty --command-fd 0 --edit-key ${{ steps.gpg-import.outputs.keyid }} << EOTRUST
63- trust
64- 5
65- y
66- quit
67- EOTRUST
68- - id : lockfile-fix
69- name : Fix yarn.lock
70- if : steps.metadata.outputs.package-ecosystem == 'npm_and_yarn'
71- run : yarn --mode=update-lockfile
72- - id : dedupe
73- name : Deduplicate dependencies
74- if : steps.metadata.outputs.package-ecosystem == 'npm_and_yarn'
75- run : yarn dedupe --mode=update-lockfile
76- - id : lockfile-push
77- name : Push yarn.lock
78- if : steps.metadata.outputs.package-ecosystem == 'npm_and_yarn'
79- run : |
80- git add yarn.lock
81- git status
82- git diff-index --quiet HEAD || git commit -m "$COMMIT_MESSAGE" && git push -f
83- env :
84- GIT_AUTHOR_EMAIL : ${{ steps.gpg-import.outputs.email }}
85- GIT_AUTHOR_NAME : ${{ steps.gpg-import.outputs.name }}
86- GIT_COMMITTER_EMAIL : ${{ steps.gpg-import.outputs.email }}
87- GIT_COMMITTER_NAME : ${{ steps.gpg-import.outputs.name }}
88- COMMIT_MESSAGE : ' [dependabot skip] chore(yarn): fix lockfile for @dependabot'
8940 - id : approve-pr
9041 name : Approve pull request
42+ if : |
43+ steps.metadata.outputs.package-ecosystem == 'github_actions' ||
44+ steps.metadata.outputs.update-type != 'version-update:semver-major'
9145 run : gh pr review ${{ github.event.number }} --approve
9246 - id : enable-auto-merge
9347 name : Enable auto-merge
0 commit comments