Repository navigation
80 lines (74 loc) · 2.78 KB
/
Copy pathauto-merge.yml
File metadata and controls
80 lines (74 loc) · 2.78 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
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Auto-merge
on:
pull_request_target:
types: [opened, reopened, synchronize]
permissions:
contents: read
jobs:
arm:
if: >-
github.event.pull_request.user.id == 115122769 &&
github.event.pull_request.user.login == 'fern-api[bot]' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.base.ref == github.event.repository.default_branch &&
startsWith(github.event.pull_request.head.ref, 'fern-bot/')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: auto-merge-${{ github.event.pull_request.number }}
cancel-in-progress: false
steps:
- name: Approve
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: gh pr review "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --approve
- name: Enable auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: gh pr merge "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --auto --squash
# The merge is made with GITHUB_TOKEN, so its push to main starts no workflow, and the push
# trigger would refuse a regeneration anyway. workflow_dispatch is the one event GITHUB_TOKEN
# may start; publish-main.yml's own gate makes this a no-op when the version is already out.
release:
needs: arm
runs-on: ubuntu-latest
timeout-minutes: 90
permissions:
actions: write
contents: read
pull-requests: read
concurrency:
group: release-after-merge-${{ github.event.pull_request.number }}
cancel-in-progress: true
steps:
- name: Wait for the merge
id: merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
for _ in $(seq 1 160); do
state=$(gh pr view "$PR_NUMBER" --repo "$GITHUB_REPOSITORY" --json state --jq .state)
case "$state" in
MERGED)
echo "merged=true" >> "$GITHUB_OUTPUT"
exit 0
;;
CLOSED)
echo "::notice::#${PR_NUMBER} closed without merging; nothing to release."
exit 0
;;
esac
sleep 30
done
echo "::warning::#${PR_NUMBER} did not merge within 80 minutes. Once it merges, run publish-main.yml from main with dry_run unchecked."
- name: Start the release
if: steps.merge.outputs.merged == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run publish-main.yml --repo "$GITHUB_REPOSITORY" --ref main -f dry_run=false