55 types : [opened, synchronize, reopened]
66
77permissions :
8+ actions : read
89 contents : write
910 pull-requests : write
1011
@@ -14,21 +15,35 @@ jobs:
1415 if : github.event.pull_request.user.login == 'dependabot[bot]'
1516 runs-on : ubuntu-latest
1617 steps :
17- - name : Wait for CI checks
18+ - name : Wait for frontend and backend CI
1819 env :
1920 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2021 PR_URL : ${{ github.event.pull_request.html_url }}
21- run : gh pr checks "$PR_URL" --watch --fail-fast
22+ run : |
23+ set -euo pipefail
24+ sha="${{ github.event.pull_request.head.sha }}"
2225
23- - uses : dependabot/fetch-metadata@v2
24- id : metadata
25- with :
26- github-token : ${{ secrets.GITHUB_TOKEN }}
26+ for attempt in $(seq 1 60); do
27+ checks="$(gh api "repos/${{ github.repository }}/commits/${sha}/check-runs?per_page=100")"
28+ ci_checks="$(jq -c '[.check_runs[] | select(.app.slug == "github-actions" and (.name == "Frontend build" or .name == "Backend build"))]' <<<"$checks")"
29+ count="$(jq 'length' <<<"$ci_checks")"
30+ failed="$(jq '[.[] | select(.status == "completed" and .conclusion != "success")] | length' <<<"$ci_checks")"
31+ passed="$(jq '[.[] | select(.status == "completed" and .conclusion == "success")] | length' <<<"$ci_checks")"
2732
28- - name : Enable auto-merge for patch and minor updates
29- if : >-
30- steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
31- steps.metadata.outputs.update-type == 'version-update:semver-minor'
33+ if [ "$failed" -gt 0 ]; then
34+ echo "Required CI failed"
35+ exit 1
36+ fi
37+ if [ "$count" -eq 2 ] && [ "$passed" -eq 2 ]; then
38+ exit 0
39+ fi
40+ sleep 10
41+ done
42+
43+ echo "Timed out waiting for required CI"
44+ exit 1
45+
46+ - name : Enable auto-merge after CI passes
3247 env :
3348 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3449 PR_URL : ${{ github.event.pull_request.html_url }}
0 commit comments