Create Tag on merge #44
Workflow file for this run
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 Tag on merge | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - develop | |
| paths: | |
| - src/** | |
| - dist/** | |
| - package*.json | |
| jobs: | |
| create-tag: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: .nvmrc | |
| # - name: Create and push new tag | |
| # run: npm run create-tag | |
| - name: Get latest commit | |
| id: get-commit | |
| run: echo "LAST_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV | |
| - name: Check for associated pull request and auto-deploy label | |
| id: should-deploy | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { owner, repo } = context.repo; | |
| const commit_sha = '${{ env.LAST_SHA }}'; | |
| const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ commit_sha, owner, repo }); | |
| if (prs?.length > 0) { | |
| const pull_number = prs[0].number; | |
| const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number }); | |
| // Extract only the Purpose section from PR description | |
| let releaseNote = pr.title; | |
| if (pr.body) { | |
| const purposeMatch = pr.body.match(/Purpose:\s*([^\n]+)/); | |
| if (purposeMatch) { | |
| releaseNote = purposeMatch[1].trim(); | |
| } | |
| } | |
| core.setOutput('pr-title', pr.title); | |
| core.setOutput('release-notes', releaseNote); | |
| core.setOutput('pr-number', pr.number); | |
| return pr.labels.some(label => label.name.includes('auto-deploy')); | |
| } | |
| return false; | |
| - name: Create GitHub Release & Deploy | |
| # if: steps.should-deploy.outputs.result == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| PR_TITLE="${{ steps.should-deploy.outputs.pr-title }}" | |
| RELEASE_NOTES="${{ steps.should-deploy.outputs.release-notes }}" | |
| PR_NUMBER="${{ steps.should-deploy.outputs.pr-number }}" | |
| # Create release notes with PR title, description, and link | |
| cat > release_notes.md << EOF | |
| ## ${PR_TITLE} | |
| ${RELEASE_NOTES} | |
| **Pull Request:** [#${PR_NUMBER}](https://github.com/${{ github.repository }}/pull/${PR_NUMBER}) | |
| EOF | |
| cat release_notes.md | |
| # gh release create $NEW_TAG --notes-file release_notes.md | |
| # git checkout $NEW_TAG | |
| # npm run update-v2-tag |