Skip to content

Commit 8ef3494

Browse files
authored
Merge pull request #443 from heckenmann/heckenmann-patch-1
Update automatic-merge.yml
2 parents 9175c11 + 2352ba1 commit 8ef3494

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed
Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
name: Automatic Merge
2-
3-
on:
4-
pull_request:
5-
types: [opened, labeled, synchronize]
6-
branches: [master]
1+
name: Dependabot auto-merge
2+
on: pull_request
73

84
permissions:
95
contents: write
@@ -12,29 +8,20 @@ permissions:
128
jobs:
139
merge:
1410
runs-on: ubuntu-latest
15-
11+
if: github.actor == 'dependabot[bot]'
1612
steps:
17-
- name: Check if Depandabot and has label
18-
id: check_conditions
19-
if: github.event_name == 'pull_request' && github.event.pull_request
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@v2
16+
with:
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
- name: Check if automatic-merge label exists
19+
if: contains(github.event.pull_request.labels.*.name, 'automatic-merge')
2020
run: |
21-
pr=$(cat "$GITHUB_EVENT_PATH" | jq -r '.pull_request')
22-
user=$(echo "$pr" | jq -r '.user.login')
23-
labels=$(echo "$pr" | jq -r '.labels[].name')
24-
if [ "$user" = "dependabot[bot]" ] && echo "$labels" | grep -q "automatic-merge"; then
25-
echo "Depandabot pull request with automatic-merge label detected."
26-
echo "::set-output name=should_merge::true"
27-
pr_url=$(echo "$pr" | jq -r '.html_url')
28-
echo "::set-env name=PR_URL::$pr_url"
29-
else
30-
echo "Not a Depandabot pull request with automatic-merge label. Exiting."
31-
echo "::set-output name=should_merge::false"
32-
fi
33-
34-
- name: Merge Pull Request
35-
if: steps.check_conditions.outputs.should_merge == 'true'
21+
echo "Automatic merge label found."
22+
- name: Enable auto-merge for Dependabot PRs
23+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' && contains(github.event.pull_request.labels.*.name, 'automatic-merge')
24+
run: gh pr merge --auto --merge "$PR_URL"
3625
env:
37-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38-
PR_URL: ${{ env.PR_URL }}
39-
run: |
40-
gh pr merge --merge --auto "${PR_URL}"
26+
PR_URL: ${{github.event.pull_request.html_url}}
27+
GH_TOKEN: ${{secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)