Last active
October 14, 2025 02:39
-
-
Save yuya-maemichi-synspective/d2ea2df78211f4924cdda8c8870bc310 to your computer and use it in GitHub Desktop.
Automate PR for Production
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
file path:
.github/workflows/release-PR.yaml