-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (43 loc) · 1.77 KB
/
Copy pathdependabot-automerge.yml
File metadata and controls
50 lines (43 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Dependabot auto-merge
on:
pull_request_target:
types: [opened, synchronize, reopened]
permissions:
actions: read
contents: write
pull-requests: write
jobs:
automerge:
name: Auto-merge safe dependency updates
if: github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Wait for frontend and backend CI
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
set -euo pipefail
sha="${{ github.event.pull_request.head.sha }}"
for attempt in $(seq 1 60); do
checks="$(gh api "repos/${{ github.repository }}/commits/${sha}/check-runs?per_page=100")"
ci_checks="$(jq -c '[.check_runs[] | select(.app.slug == "github-actions" and (.name == "Frontend build" or .name == "Backend build"))] | sort_by(.name, .started_at) | group_by(.name) | map(.[-1])' <<<"$checks")"
count="$(jq 'length' <<<"$ci_checks")"
failed="$(jq '[.[] | select(.status == "completed" and .conclusion != "success")] | length' <<<"$ci_checks")"
passed="$(jq '[.[] | select(.status == "completed" and .conclusion == "success")] | length' <<<"$ci_checks")"
if [ "$failed" -gt 0 ]; then
echo "Required CI failed"
exit 1
fi
if [ "$count" -eq 2 ] && [ "$passed" -eq 2 ]; then
exit 0
fi
sleep 10
done
echo "Timed out waiting for required CI"
exit 1
- name: Merge after CI passes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: gh pr merge --squash --delete-branch "$PR_URL"