|
| 1 | +--- |
| 2 | +name: Changelog automation |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request_target: |
| 6 | + types: [opened, edited] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read # the config file |
| 10 | + pull-requests: write # for labeling pull requests (on: pull_request_target or on: pull_request) |
| 11 | + statuses: write # to generate status |
| 12 | + checks: write # to generate status |
| 13 | + |
| 14 | +jobs: |
| 15 | + changelog-automation: |
| 16 | + name: Changelog automation |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Remove old PR labels |
| 20 | + uses: mondeja/remove-labels-gh-action@v2.0.0 |
| 21 | + with: |
| 22 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 23 | + labels: | |
| 24 | + kind/BUGFIX |
| 25 | + kind/ENHANCEMENT |
| 26 | + kind/FEATURE |
| 27 | + kind/CHANGE |
| 28 | + release-note-none |
| 29 | + - name: Add label to PR |
| 30 | + id: labeler |
| 31 | + uses: jimschubert/labeler-action@v1 |
| 32 | + with: |
| 33 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | +# Adjust the configuration in /.github/labeler.yml |
| 35 | + |
| 36 | + - name: Verify Label |
| 37 | + id: preview_label_check |
| 38 | + uses: docker://agilepathway/pull-request-label-checker:latest |
| 39 | + with: |
| 40 | + any_of: kind/BUGFIX,kind/ENHANCEMENT,kind/FEATURE,kind/CHANGE,release-note-none |
| 41 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 42 | + allow_failure: true |
| 43 | + - name: Comment on Label Check Failure |
| 44 | + uses: thollander/actions-comment-pull-request@v2.5.0 |
| 45 | + if: steps.preview_label_check.outputs.label_check == 'failure' |
| 46 | + with: |
| 47 | + message: | |
| 48 | + PR body does not contain a valid type of change. Please refer to [CONTRIBUTING.md](https://github.com/prometheus/client_golang/blob/main/CONTRIBUTING.md#how-to-write-a-pr-description) for more information. |
| 49 | + comment_tag: labelfailure |
| 50 | + mode: recreate |
| 51 | + - name: Remove Label Check Failure Comment |
| 52 | + uses: thollander/actions-comment-pull-request@v2.5.0 |
| 53 | + if: steps.preview_label_check.outputs.label_check == 'success' |
| 54 | + with: |
| 55 | + message: | |
| 56 | + PR body contains a valid type of change. |
| 57 | + comment_tag: labelfailure |
| 58 | + mode: delete |
| 59 | + create_if_not_exists: false |
| 60 | + - name: Exit on Failure |
| 61 | + if: steps.preview_label_check.outputs.label_check == 'failure' |
| 62 | + run: exit 1 |
0 commit comments