Create Release Branch and PR #84
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 Release Branch and PR | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| create-release-branch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out the code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: dev | |
| - name: Get release date and branch name | |
| run: | | |
| RELEASE_DATE=$(date +'%Y-%m-%d') | |
| echo "RELEASE_DATE=$RELEASE_DATE" >> $GITHUB_ENV | |
| echo "BRANCH_NAME=release/$RELEASE_DATE" >> $GITHUB_ENV | |
| - name: Create or update branch | |
| run: | | |
| git checkout -B $BRANCH_NAME | |
| git push --force --set-upstream origin $BRANCH_NAME | |
| - name: Create pull request using GitHub CLI | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Create PR if it doesn't already exist | |
| if ! gh pr view "$BRANCH_NAME" --json number &>/dev/null; then | |
| gh pr create \ | |
| --base main \ | |
| --head "$BRANCH_NAME" \ | |
| --title "release: $RELEASE_DATE" \ | |
| --body ":rocket: Automated release PR" | |
| fi | |
| # Always ensure labels are applied (handles 502 / retry scenarios) | |
| gh pr edit "$BRANCH_NAME" --add-label "release,auto-pr" |