2626 auto-approve-merge :
2727 if : github.event.pull_request.user.login == 'dependabot[bot]'
2828 runs-on : ubuntu-latest-low
29+ env :
30+ # env variable for maintainers: 'true' allows to auto-merge 1.0.2 -> 2.0.0
31+ ALLOW_MAJOR : false
32+ # env variable for maintainers: 'true' allows to auto-merge 1.0.2 -> 1.1.0
33+ ALLOW_MINOR : true
34+ # env variable for maintainers: RegExp string to ignore some dependencies from auto-approve and auto-merge
35+ IGNORE_PATTERN : ' '
2936 permissions :
3037 # for auto-approve step to work
3138 pull-requests : write
@@ -46,20 +53,49 @@ jobs:
4653
4754 - name : Dependabot metadata
4855 id : metadata
49- uses : dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0
56+ if : startsWith(steps.branchname.outputs.branch, 'dependabot/')
57+ uses : dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0
5058 with :
5159 github-token : ${{ secrets.GITHUB_TOKEN }}
5260
53- - name : GitHub actions bot approve
61+ - name : Check for ignored dependencies in the PR
62+ id : validate
5463 if : startsWith(steps.branchname.outputs.branch, 'dependabot/')
64+ env :
65+ IGNORE_PATTERN : ${{ env.IGNORE_PATTERN }}
66+ DEPENDENCY_NAMES : ${{ steps.metadata.outputs.dependency-names }}
67+ run : |
68+ if [[ -z ${IGNORE_PATTERN} ]]; then
69+ echo "ignore=false" >> "$GITHUB_OUTPUT"
70+ elif [[ -z ${DEPENDENCY_NAMES} ]]; then
71+ echo "ignore=false" >> "$GITHUB_OUTPUT"
72+ elif [[ ${DEPENDENCY_NAMES} =~ ${IGNORE_PATTERN} ]]; then
73+ echo "ignore=true" >> "$GITHUB_OUTPUT"
74+ fi
75+
76+ - name : GitHub actions bot approve
77+ id : auto_approve
78+ if : ${{
79+ startsWith(steps.branchname.outputs.branch, 'dependabot/')
80+ && steps.validate.outputs.ignore != 'true'
81+ }}
5582 run : gh pr review --approve "$PR_URL"
5683 env :
5784 PR_URL : ${{ github.event.pull_request.html_url }}
5885 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5986
6087 # Enable GitHub auto merge
6188 - name : Auto merge
62- uses : alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # 2.0.0
63- if : startsWith(steps.branchname.outputs.branch, 'dependabot/') && (github.event.action == 'opened' || github.event.action == 'reopened') && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')
89+ uses : alexwilson/enable-github-automerge-action@2c32e18a76e0726ffe7a573bfff2d42a20885126 # 3.0.0
90+ if : ${{
91+ startsWith(steps.branchname.outputs.branch, 'dependabot/')
92+ && steps.auto_approve.conclusion == 'success'
93+ && (github.event.action == 'opened' || github.event.action == 'reopened')
94+ && (
95+ steps.metadata.outputs.update-type == 'version-update:semver-patch'
96+ || (fromJSON(env.ALLOW_MINOR) && steps.metadata.outputs.update-type == 'version-update:semver-minor')
97+ || (fromJSON(env.ALLOW_MAJOR) && steps.metadata.outputs.update-type == 'version-update:semver-major')
98+ )
99+ }}
64100 with :
65101 github-token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments