Skip to content

Commit 297da75

Browse files
committed
feat: add optional label check for auto-approve action
1 parent 3d780ad commit 297da75

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

.github/renovate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"description": "Base rule - packageFileDir and depName separation",
2222
"matchPaths": ["**"],
2323
"automerge": true,
24-
"groupName": "{{packageFileDir}} {{depName}}"
24+
"groupName": "{{packageFileDir}} {{depName}}",
25+
"addLabels": ["🤖 automerge"]
2526
},
2627

2728
{

.github/workflows/renovate-auto-approve.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ jobs:
1313
runs-on: ubuntu-latest
1414
if: github.actor == 'renovate[bot]'
1515
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
1916
- name: Auto-approve and Merge
2017
uses: ./auto-approve
2118
with:
2219
app-id: ${{ vars.APP_ID }}
2320
private-key: ${{ secrets.APP_PRIVATE_KEY }}
21+
auto-merge-label: '🤖 automerge'

auto-approve/action.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ inputs:
77
private-key:
88
description: 'GitHub App private key'
99
required: true
10+
auto-merge-label:
11+
description: 'Label required for auto-merge. If empty, all PRs are merged.'
12+
required: false
13+
default: ''
1014

1115
runs:
1216
using: 'composite'
@@ -26,7 +30,21 @@ runs:
2630
- name: Auto-merge PRs
2731
continue-on-error: true
2832
shell: bash
29-
run: gh pr merge --squash --auto "$PR_URL"
33+
run: |
34+
TARGET_LABEL="${{ inputs.auto-merge-label }}"
35+
36+
if [[ -n "$TARGET_LABEL" ]]; then
37+
echo "Checking for label: $TARGET_LABEL"
38+
CURRENT_LABELS=$(gh pr view "$PR_URL" --json labels --jq '.labels[].name')
39+
if ! echo "$CURRENT_LABELS" | grep -Fqx "$TARGET_LABEL"; then
40+
echo "::notice::Skipping auto-merge because label '$TARGET_LABEL' is missing."
41+
exit 0
42+
fi
43+
echo "Label '$TARGET_LABEL' found."
44+
fi
45+
46+
echo "Proceeding with auto-merge..."
47+
gh pr merge --squash --auto "$PR_URL"
3048
env:
3149
PR_URL: ${{ github.event.pull_request.html_url }}
3250
GH_TOKEN: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)