Skip to content

build: add comment about event handling #14

build: add comment about event handling

build: add comment about event handling #14

# Create or update merge-to-master pull requests for production releases
# Note that by design, creating or editing a PR will not trigger a downstream `pull_request` event as this could lead to recursion
name: Release
on:
push:
branches:
- develop
- sh51/create-release-pr-action
jobs:
pull_request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create or update PR
env:
GH_TOKEN: ${{ github.token }}
run: |
PR_NUMBERS=$(gh api repos/${{ github.repository }}/compare/master...develop --jq '.commits[] | select(.commit.message | startswith("Merge pull request")) | .commit.message | capture("#(?<pr_number>\\d+)") | "#\(.pr_number)"')
PR_BODY="#### Changes proposed in this pull request
$(echo "$PR_NUMBERS" | sed 's/^/- /')
#### Instructions for Reviewers
&nbsp; &nbsp; \- _Check stories are ready for release_
&nbsp; &nbsp; \- _Check for any database migrations_
&nbsp; &nbsp; \- _Check for debug code_
&nbsp; &nbsp; \- _Check version is appropiate_
This description will be overwritten on the next push
This PR was auto-generated on $(TZ=Europe/London date --iso-8601=seconds)"
# Check if a PR already exists
EXISTING_PR=$(gh pr list --base master --head develop --json number --jq '.[0].number')
if [ -z "$EXISTING_PR" ]; then
gh pr create --base master --head develop --title "Merge Develop into Master" --body "$PR_BODY"
else
gh pr edit "$EXISTING_PR" --body "$PR_BODY"
fi