-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 1.91 KB
/
Copy pathnightly-release.yml
File metadata and controls
67 lines (59 loc) · 1.91 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Nightly Release
on:
schedule:
- cron: '0 4 * * *'
workflow_dispatch:
jobs:
auto-merge-release:
runs-on: ubuntu-latest
if: ${{ vars.NIGHTLY_RELEASE != 'false' }}
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Find release-please PR
id: find-pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR=$(gh pr list \
--head release-please--branches--main \
--json number,mergeable,mergeStateStatus \
--jq '.[0]' 2>/dev/null || echo '{}')
NUMBER=$(echo "$PR" | jq -r '.number // empty')
if [ -z "$NUMBER" ]; then
echo "No release-please PR found"
echo "found=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "found=true" >> "$GITHUB_OUTPUT"
echo "number=$NUMBER" >> "$GITHUB_OUTPUT"
- name: Check CI status
if: steps.find-pr.outputs.found == 'true'
id: ci-check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.find-pr.outputs.number }}
run: |
CHECKS=$(gh pr checks "$PR_NUMBER" 2>&1 || true)
if echo "$CHECKS" | grep -qE "fail|pending"; then
echo "CI not green — skipping auto-merge"
echo "$CHECKS"
echo "green=false" >> "$GITHUB_OUTPUT"
else
echo "CI green"
echo "green=true" >> "$GITHUB_OUTPUT"
fi
- name: Auto-merge release PR
if: >-
steps.find-pr.outputs.found == 'true' &&
steps.ci-check.outputs.green == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ steps.find-pr.outputs.number }}
run: |
gh pr merge "$PR_NUMBER" \
--squash \
--auto \
--subject "chore: release $(date +%Y-%m-%d)"