Skip to content

Commit f0ce225

Browse files
committed
feat: add env variable to ignore auto-approval and auto-merge
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
1 parent 634aeaa commit f0ce225

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

workflow-templates/dependabot-approve-merge.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
auto-approve-merge:
2727
if: github.event.pull_request.user.login == 'dependabot[bot]'
2828
runs-on: ubuntu-latest-low
29+
# env variable for maintainers: RegExp string to ignore some dependencies from auto-approve and auto-merge
30+
IGNORE_PATTERN: ''
2931
permissions:
3032
# for auto-approve step to work
3133
pull-requests: write
@@ -51,10 +53,26 @@ jobs:
5153
with:
5254
github-token: ${{ secrets.GITHUB_TOKEN }}
5355

56+
- name: Check for ignored dependencies in the PR
57+
id: validate
58+
if: startsWith(steps.branchname.outputs.branch, 'dependabot/')
59+
env:
60+
IGNORE_PATTERN: ${{ env.IGNORE_PATTERN }}
61+
DEPENDENCY_NAMES: ${{ steps.metadata.outputs.dependency-names }}
62+
run: |
63+
if [[ -z ${IGNORE_PATTERN} ]]; then
64+
echo "ignore=false" >> "$GITHUB_OUTPUT"
65+
elif [[ -z ${DEPENDENCY_NAMES} ]]; then
66+
echo "ignore=false" >> "$GITHUB_OUTPUT"
67+
elif [[ ${DEPENDENCY_NAMES} =~ ${IGNORE_PATTERN} ]]; then
68+
echo "ignore=true" >> "$GITHUB_OUTPUT"
69+
fi
70+
5471
- name: GitHub actions bot approve
5572
id: auto_approve
5673
if: ${{
5774
startsWith(steps.branchname.outputs.branch, 'dependabot/')
75+
&& steps.validate.outputs.ignore != 'true'
5876
}}
5977
run: gh pr review --approve "$PR_URL"
6078
env:
@@ -66,6 +84,7 @@ jobs:
6684
uses: alexwilson/enable-github-automerge-action@56e3117d1ae1540309dc8f7a9f2825bc3c5f06ff # v2.0.0
6785
if: ${{
6886
startsWith(steps.branchname.outputs.branch, 'dependabot/')
87+
&& steps.auto_approve.conclusion == 'success'
6988
&& (github.event.action == 'opened' || github.event.action == 'reopened')
7089
&& (
7190
steps.metadata.outputs.update-type == 'version-update:semver-patch'

0 commit comments

Comments
 (0)