Changelog #37
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: Changelog | |
| on: | |
| schedule: | |
| # Every day at 09:00 UTC | |
| - cron: '0 9 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: | |
| group: changelog-tracker | |
| cancel-in-progress: false | |
| jobs: | |
| check-changelog: | |
| name: Sync | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Prepare changelog branch | |
| id: branch | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| EXISTING_BRANCH=$(gh pr list --label "changelog" --state open --json headRefName --jq '.[0].headRefName // empty') | |
| if [ -n "$EXISTING_BRANCH" ]; then | |
| BRANCH="$EXISTING_BRANCH" | |
| REUSE_BRANCH=true | |
| else | |
| BRANCH="chore/changelog-update" | |
| REUSE_BRANCH=false | |
| fi | |
| echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin main | |
| if [ "$REUSE_BRANCH" = "true" ] && git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then | |
| git fetch origin "$BRANCH" | |
| git checkout -B "$BRANCH" "origin/$BRANCH" | |
| git rebase origin/main | |
| else | |
| git checkout -B "$BRANCH" origin/main | |
| fi | |
| - name: Fetch RSS and update changelog | |
| env: | |
| CHANGELOG_PR_BODY_FILE: ${{ runner.temp }}/pr-body.md | |
| run: node scripts/crawl-changelog.mjs | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| if git diff --quiet CLOUD_API_CHANGELOG.md; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Create PR with updated changelog | |
| if: steps.diff.outputs.changed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| CHANGELOG_PR_BODY_FILE: ${{ runner.temp }}/pr-body.md | |
| run: | | |
| BRANCH="${{ steps.branch.outputs.branch }}" | |
| git add CLOUD_API_CHANGELOG.md | |
| git commit -m "chore: update Cloud API changelog from RSS feed" | |
| git push --force-with-lease --set-upstream origin "$BRANCH" | |
| EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number // empty') | |
| if [ -n "$EXISTING_PR" ]; then | |
| gh pr comment "$EXISTING_PR" --body-file "$CHANGELOG_PR_BODY_FILE" | |
| else | |
| gh pr create \ | |
| --title "chore: new Cloud API changelog entries detected" \ | |
| --body-file "$CHANGELOG_PR_BODY_FILE" \ | |
| --label "changelog" \ | |
| --head "$BRANCH" \ | |
| --base main | |
| fi |