|
13 | 13 | jobs: |
14 | 14 | changelog: |
15 | 15 | runs-on: ubuntu-latest |
16 | | - if: | |
17 | | - !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') |
18 | | - && github.actor != 'opentelemetrybot' |
19 | | -
|
20 | 16 | steps: |
21 | | - - uses: actions/checkout@v4 |
| 17 | + - name: Checkout repo @ SHA - ${{ github.sha }} |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Fetch base branch - ${{ github.base_ref }} |
| 21 | + run: git fetch origin ${{ github.base_ref }} --depth=1 |
22 | 22 |
|
23 | | - - name: Check for CHANGELOG changes |
| 23 | + - name: Ensure no changes to CHANGELOG.md |
| 24 | + if: | |
| 25 | + !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') |
| 26 | + && github.event.pull_request.user.login != 'opentelemetrybot' |
24 | 27 | run: | |
25 | | - # Only the latest commit of the feature branch is available |
26 | | - # automatically. To diff with the base branch, we need to |
27 | | - # fetch that too (and we only need its latest commit). |
28 | | - git fetch origin ${{ github.base_ref }} --depth=1 |
29 | | - if [[ $(git diff --name-only FETCH_HEAD | grep CHANGELOG) ]] |
| 28 | + # If there are any changes to CHANGELOG.md, fail. |
| 29 | + if [[ $(git diff --name-only FETCH_HEAD -- 'CHANGELOG.md') ]] |
30 | 30 | then |
31 | | - echo "A CHANGELOG was modified. Looks good!" |
| 31 | + echo "CHANGELOG.md should not be directly modified." |
| 32 | + echo "Please add a entry file to the .changelog/ directory instead." |
| 33 | + echo "See CONTRIBUTING.md for more details." |
| 34 | + echo "Alternately, add the \"Skip Changelog\" label if this job should be skipped." |
| 35 | + false |
32 | 36 | else |
33 | | - echo "No CHANGELOG was modified." |
34 | | - echo "Please add a CHANGELOG entry, or add the \"Skip Changelog\" label if not required." |
| 37 | + echo "CHANGELOG.md was not modified." |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Ensure changelog entry addition |
| 41 | + if: | |
| 42 | + !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') |
| 43 | + && github.event.pull_request.user.login != 'opentelemetrybot' |
| 44 | + run: | |
| 45 | + if [[ -z $(git diff --diff-filter=A --name-only FETCH_HEAD -- './.changelog/${{ github.event.pull_request.number }}*') ]] |
| 46 | + then |
| 47 | + echo "No changelog entry was added to the ./.changelog/ directory." |
| 48 | + echo "Please add a changelog entry file to the ./.changelog/ directory." |
| 49 | + echo "See CONTRIBUTING.md for more details." |
| 50 | + echo "Alternately, add the \"Skip Changelog\" label if this job should be skipped." |
35 | 51 | false |
| 52 | + else |
| 53 | + echo "A changelog entry was added to the ./.changelog/ directory." |
36 | 54 | fi |
| 55 | +
|
| 56 | + - name: Install towncrier |
| 57 | + run: pip install towncrier |
| 58 | + |
| 59 | + - name: Generate changelog |
| 60 | + run: towncrier build --draft --version "Unreleased" |
0 commit comments