|
| 1 | +# This action requires that any PR targeting the main branch should touch at |
| 2 | +# least one CHANGELOG file. If a CHANGELOG entry is not required, add the "Skip |
| 3 | +# Changelog" label to disable this action. |
| 4 | + |
| 5 | +name: 'Changelog' |
| 6 | + |
| 7 | +on: |
| 8 | + pull_request: |
| 9 | + types: [opened, ready_for_review, synchronize, reopened, labeled, unlabeled] |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ${{ github.workflow }}-${{ github.head_ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + changelog: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + if: >- |
| 21 | + ${{ |
| 22 | + !contains(github.event.pull_request.labels.*.name, 'dependencies') && |
| 23 | + !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && |
| 24 | + !contains(github.event.pull_request.title, '[chore]') |
| 25 | + }} |
| 26 | + env: |
| 27 | + PR_HEAD: ${{ github.event.pull_request.head.sha }} |
| 28 | + steps: |
| 29 | + - name: Checkout Repo |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + - name: Setup Go |
| 34 | + uses: actions/setup-go@v4 |
| 35 | + with: |
| 36 | + go-version: ~1.21.6 |
| 37 | + - name: Cache Go |
| 38 | + id: go-cache |
| 39 | + uses: actions/cache@v3 |
| 40 | + with: |
| 41 | + path: | |
| 42 | + ~/go/bin |
| 43 | + ~/go/pkg/mod |
| 44 | + key: changelog-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 45 | + |
| 46 | + - name: Ensure no changes to the CHANGELOG.md |
| 47 | + run: | |
| 48 | + if [[ $(git diff --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./CHANGELOG*.md) ]] |
| 49 | + then |
| 50 | + echo "CHANGELOG.md should not be directly modified." |
| 51 | + echo "Please add a .yaml file to the ./.chloggen/ directory." |
| 52 | + echo "See CONTRIBUTING.md for more details." |
| 53 | + echo "Alternately, add either \"[chore]\" to the title of the pull \ request or add the \"Skip Changelog\" label if this job should be skipped." |
| 54 | + false |
| 55 | + else |
| 56 | + echo "CHANGELOG.md was not modified." |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Ensure ./.chloggen/*.yaml addition(s) |
| 60 | + run: | |
| 61 | + if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./.chloggen | grep -c \\.yaml) ]] |
| 62 | + then |
| 63 | + echo "No changelog entry was added to the ./.chloggen/ directory." |
| 64 | + echo "Please add a .yaml file to the ./.chloggen/ directory." |
| 65 | + echo "See CONTRIBUTING.md for more details." |
| 66 | + echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped." |
| 67 | + false |
| 68 | + else |
| 69 | + echo "A changelog entry was added to the ./.chloggen/ directory." |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Validate ./.chloggen/*.yaml changes |
| 73 | + run: | |
| 74 | + make chlog-validate \ |
| 75 | + || { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; } |
| 76 | +
|
| 77 | + # In order to validate any links in the yaml file, render the config to markdown |
| 78 | + - name: Render .chloggen changelog entries |
| 79 | + run: make chlog-preview > changelog_preview.md |
| 80 | + - name: Install markdown-link-check |
| 81 | + run: npm install -g markdown-link-check |
| 82 | + - name: Run markdown-link-check |
| 83 | + run: | |
| 84 | + markdown-link-check \ |
| 85 | + --verbose \ |
| 86 | + --config .markdown_link_check_config.json \ |
| 87 | + changelog_preview.md \ |
| 88 | + || { echo "Check that anchor links are lowercase"; exit 1; } |
0 commit comments