| 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, edited] |
| 10 |
branches: |
| 11 |
- main |
| 12 |
merge_group: |
| 13 |
types: [checks_requested] |
| 14 |
|
| 15 |
concurrency: |
| 16 |
group: ${{ github.workflow }}-${{ github.ref_name }} |
| 17 |
cancel-in-progress: true |
| 18 |
|
| 19 |
permissions: read-all |
| 20 |
|
| 21 |
jobs: |
| 22 |
changelog: |
| 23 |
runs-on: ubuntu-latest |
| 24 |
if: ${{ github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !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@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 |
| 31 |
with: |
| 32 |
fetch-depth: 0 |
| 33 |
- name: Setup Go |
| 34 |
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 |
| 35 |
with: |
| 36 |
go-version: oldstable |
| 37 |
cache: false |
| 38 |
|
| 39 |
- name: Cache Go |
| 40 |
id: go-cache |
| 41 |
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 |
| 42 |
with: |
| 43 |
path: | |
| 44 |
~/go/bin |
| 45 |
~/go/pkg/mod |
| 46 |
key: go-cache-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/go.sum') }} |
| 47 |
|
| 48 |
- name: Ensure no changes to the CHANGELOG.md or CHANGELOG-API.md |
| 49 |
run: | |
| 50 |
if [[ $(git diff --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./CHANGELOG*.md) ]] |
| 51 |
then |
| 52 |
echo "CHANGELOG.md and CHANGELOG-API.md should not be directly modified." |
| 53 |
echo "Please add a .yaml file to the ./.chloggen/ directory." |
| 54 |
echo "See CONTRIBUTING.md for more details." |
| 55 |
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped." |
| 56 |
false |
| 57 |
else |
| 58 |
echo "CHANGELOG.md and CHANGELOG-API.md were not modified." |
| 59 |
fi |
| 60 |
|
| 61 |
- name: Ensure changelog config.yaml is up to date |
| 62 |
run: | |
| 63 |
make generate-chloggen-components |
| 64 |
if [[ $(git diff --name-only) ]]; then |
| 65 |
echo ".chloggen/config.yaml is out of date. Please run 'make generate-chloggen-components' and commit the changes." |
| 66 |
false |
| 67 |
else |
| 68 |
echo ".chloggen/config.yaml is up to date." |
| 69 |
fi |
| 70 |
git checkout $PR_HEAD -- ./.chloggen/config.yaml |
| 71 |
|
| 72 |
- name: Ensure ./.chloggen/*.yaml addition(s) |
| 73 |
run: | |
| 74 |
if [[ 1 -gt $(git diff --diff-filter=A --name-only $(git merge-base origin/main $PR_HEAD) $PR_HEAD ./.chloggen | grep -c \\.yaml) ]] |
| 75 |
then |
| 76 |
echo "No changelog entry was added to the ./.chloggen/ directory." |
| 77 |
echo "Please add a .yaml file to the ./.chloggen/ directory." |
| 78 |
echo "See CONTRIBUTING.md for more details." |
| 79 |
echo "Alternately, add either \"[chore]\" to the title of the pull request or add the \"Skip Changelog\" label if this job should be skipped." |
| 80 |
false |
| 81 |
else |
| 82 |
echo "A changelog entry was added to the ./.chloggen/ directory." |
| 83 |
fi |
| 84 |
|
| 85 |
- name: Validate ./.chloggen/*.yaml changes |
| 86 |
run: | |
| 87 |
make chlog-validate \ |
| 88 |
|| { echo "New ./.chloggen/*.yaml file failed validation."; exit 1; } |
| 89 |
|
| 90 |
# In order to validate any links in the yaml file, render the config to markdown |
| 91 |
- name: Render .chloggen changelog entries |
| 92 |
run: make chlog-preview > changelog_preview.md |
| 93 |
- name: Link Checker |
| 94 |
id: lychee |
| 95 |
uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2.7.0 |
| 96 |
with: |
| 97 |
args: "--verbose --no-progress ./changelog_preview.md --config .github/lychee.toml" |
| 98 |
failIfEmpty: false |