Skip to content

update: Easy to see functions #35

update: Easy to see functions

update: Easy to see functions #35

Workflow file for this run

name: Create release branch PR
on:
pull_request:
types: [closed]
branches:
- main
jobs:
create-release-pr:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: fetch previous tag
id: pre_tag
run: |
pre_tag=$(gh api repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "pre_tag=$pre_tag" >> $GITHUB_OUTPUT
- name: fetch list of merged PRs since latest release
id: merged_prs
run: |
previous_tag=${{ steps.pre_tag.outputs.pre_tag }}
merged_prs=$(gh api --method POST /repos/{owner}/{repo}/releases/generate-notes -f "tag_name=tmp" -f "target_commitish=main" -f "previous_tag_name=$previous_tag" | jq -r .body)
echo "merged_prs<<EOF" >> $GITHUB_OUTPUT
echo "$merged_prs" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create PR to release branch
run: |
PR_EXISTS=$(gh pr list --head main --base release --state open --json number --jq '.[].number')
merged_prs="${{ steps.merged_prs.outputs.merged_prs }}"
pr_body=$merged_prs
if [ -z "$PR_EXISTS" ]; then
gh pr create --title "Merge main into release" --body "$pr_body" --base release --head main
else
gh pr edit $PR_EXISTS --body "$pr_body"
gh pr comment $PR_EXISTS --body "Additional PRs merged:\n$merged_prs"
fi