Add release notes automation #8
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: Generate Release Notes PR | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| REPO_NAME: migration-planner | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| release-notes: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install gren | |
| run: npm install -g github-release-notes | |
| - name: Get latest tag | |
| id: tag | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Use the variable via env context | |
| TAG=$(gh api repos/kubev2v/migration-planner/tags --jq '.[0].name') | |
| echo "tag=$TAG" >> $GITHUB_OUTPUT | |
| - name: Generate release notes to file | |
| env: | |
| GREN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Use the variable via env context | |
| gren release \ | |
| --repo migration-planner \ | |
| > release-notes.md | |
| - name: Create branch | |
| run: | | |
| git checkout -b release-notes-${{ steps.tag.outputs.tag }} | |
| - name: Commit file | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add release-notes.md | |
| git commit -m "Add release notes for ${{ steps.tag.outputs.tag }}" | |
| - name: Push branch | |
| run: | | |
| git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ env.REPO_NAME }}.git release-notes-${{ steps.tag.outputs.tag }} | |
| - name: Create Pull Request | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh pr create \ | |
| --title "Release notes for ${{ steps.tag.outputs.tag }}" \ | |
| --body "Auto-generated release notes for tag ${{ steps.tag.outputs.tag }}" \ | |
| --head release-notes-${{ steps.tag.outputs.tag }} \ | |
| --base main |