Skip to content

go-live

go-live #3

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@0d381219ddf674d61a7572ddd19d7941e271515c # v2.9.0
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@692973e3d937129bcbf40652eb9f2f61becf3332 # 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