Repository navigation
Release notes sync #16
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: "Release notes sync" | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 6 * * 1" | |
| permissions: | |
| contents: read | |
| jobs: | |
| sync-release-notes: | |
| name: "Sync release notes" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - name: "Generate GitHub App token" | |
| id: app-token | |
| uses: actions/create-github-app-token@v3.2.0 | |
| with: | |
| client-id: "${{ secrets.APP_CLIENT_ID }}" | |
| private-key: "${{ secrets.APP_PEM_FILE }}" | |
| - name: "Checkout code" | |
| uses: actions/checkout@v4 | |
| - name: "Update release notes data" | |
| uses: ./.github/actions/release-notes | |
| env: | |
| JIRA_TOKEN: "${{ secrets.JIRA_TOKEN }}" | |
| JIRA_BASE_URL: "${{ secrets.JIRA_URL }}/rest/api/2" | |
| - name: "Detect release notes changes" | |
| id: changes | |
| shell: bash | |
| run: | | |
| if git diff --quiet -- docs/_data/release-notes.json; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: "Commit and raise pull request" | |
| if: steps.changes.outputs.has_changes == 'true' | |
| env: | |
| GH_TOKEN: "${{ steps.app-token.outputs.token }}" | |
| shell: bash | |
| run: | | |
| DEFAULT_SHA=$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/main" --jq '.object.sha') | |
| # Create branch pointing to main, or force-reset it if it already exists | |
| gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \ | |
| -f ref="refs/heads/automation/release-notes-cache" \ | |
| -f sha="$DEFAULT_SHA" 2>/dev/null || \ | |
| gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/heads/automation/release-notes-cache" \ | |
| -f sha="$DEFAULT_SHA" \ | |
| -F force=true | |
| # Commits via the Contents API are automatically verified by GitHub | |
| FILE_SHA=$(gh api "repos/$GITHUB_REPOSITORY/contents/docs/_data/release-notes.json?ref=automation/release-notes-cache" --jq '.sha' 2>/dev/null || echo "") | |
| FILE_CONTENT=$(base64 -w 0 docs/_data/release-notes.json) | |
| if [ -n "$FILE_SHA" ]; then | |
| gh api --method PUT "repos/$GITHUB_REPOSITORY/contents/docs/_data/release-notes.json" \ | |
| -f message="sync release notes" \ | |
| -f content="$FILE_CONTENT" \ | |
| -f sha="$FILE_SHA" \ | |
| -f branch="automation/release-notes-cache" | |
| else | |
| gh api --method PUT "repos/$GITHUB_REPOSITORY/contents/docs/_data/release-notes.json" \ | |
| -f message="sync release notes" \ | |
| -f content="$FILE_CONTENT" \ | |
| -f branch="automation/release-notes-cache" | |
| fi | |
| gh pr create \ | |
| --title "CCM-18043: Sync release notes" \ | |
| --body "## Summary | |
| This PR syncs the release notes generated from JIRA for the last year. | |
| - Trigger: \`${{ github.event_name }}\` | |
| - Source: \`JIRA_URL secret (expanded to REST API base path)\`" \ | |
| --base main \ | |
| --head automation/release-notes-cache 2>/dev/null || echo "PR already exists" |