Skip to content

Instantly share code, notes, and snippets.

@yuya-maemichi-synspective
Last active October 14, 2025 02:39
Show Gist options
  • Save yuya-maemichi-synspective/d2ea2df78211f4924cdda8c8870bc310 to your computer and use it in GitHub Desktop.
Save yuya-maemichi-synspective/d2ea2df78211f4924cdda8c8870bc310 to your computer and use it in GitHub Desktop.
Automate PR for Production
name: Create and Update Pull Request for Production Release
on:
push:
branches:
- main
jobs:
create_and_update_pr:
runs-on: ubuntu-latest
steps:
- id: gh_pr_create
name: Create Pull Request if not exists
run: >-
gh pr view ||
gh pr create \
--draft \
--base=production \
--title="production release $(date -I'date')" \
--body-file=- <<'EOL'
# Production Release
## Changes
<!-- PR list begin -->
<!-- PR list end -->
## Foo
${{ vars.BAR }}
EOL
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
- id: gh_pr_edit
name: Update Pull Request body and title
run: |
gh pr view --json='commits' \
--jq='.commits[].messageHeadline|match("#\\d+")|.string|"* \(.)"' \
>${PR_LIST_FILENAME}
gh pr view --json='body' --jq='.body' |
awk -v lines=${PR_LIST_FILENAME} '
/<!-- PR list begin -->/ {in_ls=1; print; while((getline line<lines) >0) print line}
/<!-- PR list end -->/ {in_ls=0}
in_ls==0 {print}
' |
gh pr edit \
--body-file=- \
--title="production release $(date -I'date')"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_LIST_FILENAME: PR-list.txt
@yuya-maemichi-synspective
Copy link
Author

yuya-maemichi-synspective commented Oct 8, 2025

file path: .github/workflows/release-PR.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment