| 1 | name: Changelog |
| 2 | |
| 3 | on: |
| 4 | pull_request: |
| 5 | types: |
| 6 | - opened |
| 7 | - edited |
| 8 | - synchronize |
| 9 | - reopened |
| 10 | - labeled |
| 11 | - unlabeled |
| 12 | paths: |
| 13 | - '**.go' |
| 14 | - '**/go.mod' |
| 15 | - '**/go.sum' |
| 16 | |
| 17 | jobs: |
| 18 | changelog: |
| 19 | if: contains(github.event.pull_request.title, '[skip changelog]') == false && |
| 20 | contains(github.event.pull_request.labels.*.name, 'skip/changelog') == false |
| 21 | runs-on: ubuntu-latest |
| 22 | name: Changelog |
| 23 | steps: |
| 24 | - id: changelog |
| 25 | env: |
| 26 | GITHUB_TOKEN: ${{ github.token }} |
| 27 | ENDPOINT: repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files |
| 28 | SELECTOR: 'map(select(.filename | startswith("docs/changelogs/"))) | length' |
| 29 | run: gh api "$ENDPOINT" --jq "$SELECTOR" | xargs -I{} echo "modified={}" | tee -a $GITHUB_OUTPUT |
| 30 | - if: steps.changelog.outputs.modified == '0' |
| 31 | env: |
| 32 | MESSAGE: | |
| 33 | docs/changelogs/ was not modified in this PR. Please do one of the following: |
| 34 | - add a changelog entry |
| 35 | - add `[skip changelog]` to the PR title |
| 36 | - label the PR with `skip/changelog` |
| 37 | run: | |
| 38 | echo "::error::${MESSAGE//$'\n'/%0A}" |
| 39 | exit 1 |