-
Notifications
You must be signed in to change notification settings - Fork 106
59 lines (50 loc) · 1.67 KB
/
dispatch-merge-main-to-live.yml
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
name: go-live
on:
workflow_dispatch:
inputs:
reason:
description: "The reason for running the workflow"
required: true
default: "Need to update live now, before daily scheduled run."
permissions:
contents: read
jobs:
go-live:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
permissions:
contents: write
pull-requests: write
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- name: "Print manual run reason"
if: github.event_name == 'workflow_dispatch'
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Check out code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # main
- name: Check for existing PR
id: exists
run: |
result=$(gh pr list --base live --head main --json number --jq '.[0].number' || echo "")
echo "PR_NUMBER=$result" >> $GITHUB_OUTPUT
shell: bash
- name: Create pull request
id: create
if: steps.exists.outputs.PR_NUMBER == ''
run: |
gh pr create \
--title "✅ Merge \`main\` into \`live\`" \
--body "🤖 Queue merge when ready..." \
--base live \
--head main
echo "CREATED=true" >> $GITHUB_OUTPUT
- name: Enable auto-merge for the pull request
if: steps.create.outputs.CREATED == 'true'
run: |
PR_NUMBER=$(gh pr list --base live --head main --json number --jq '.[0].number')
gh pr merge $PR_NUMBER --merge --auto