Improve changelog check action (#949)

Make check faster when `skip news` label is present
Add `name:` root field
This commit is contained in:
Evgen Fil 2022-06-26 18:22:32 +05:00 committed by GitHub
parent 70088cdd65
commit 2cb0fd1c4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,3 +1,4 @@
name: "Check that changes are described"
on: on:
pull_request_target: pull_request_target:
types: types:
@ -8,31 +9,32 @@ on:
- "unlabeled" - "unlabeled"
jobs: jobs:
check_changes: changes-required:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: "Check that changes is described" if: "!contains(github.event.pull_request.labels.*.name, 'skip news')"
steps: steps:
- name: "Checkout code" - name: Checkout code
uses: actions/checkout@master uses: actions/checkout@master
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: '0' fetch-depth: '0'
- name: Set up Python 3.10 - name: Set up Python 3.10
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: "3.10" python-version: "3.10"
- name: Install towncrier - name: Install towncrier
run: pip install towncrier run: pip install towncrier
- name: "Check changelog" - name: Check changelog
if: "!contains(github.event.pull_request.labels.*.name, 'skip news')"
env: env:
BASE_BRANCH: ${{ github.base_ref }} BASE_BRANCH: ${{ github.base_ref }}
run: | run: |
git fetch --no-tags origin +refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH} git fetch --no-tags origin +refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}
towncrier check --compare-with origin/${BASE_BRANCH} towncrier check --compare-with origin/${BASE_BRANCH}
- name: Find Comment - name: Find bot comment
if: "always()" if: "always()"
uses: peter-evans/find-comment@v2 uses: peter-evans/find-comment@v2
id: fc id: fc
@ -41,7 +43,7 @@ jobs:
comment-author: 'github-actions[bot]' comment-author: 'github-actions[bot]'
body-includes: Changelog body-includes: Changelog
- name: Create fail comment - name: Ask for changelog
if: "failure()" if: "failure()"
uses: peter-evans/create-or-update-comment@v2 uses: peter-evans/create-or-update-comment@v2
with: with:
@ -57,7 +59,7 @@ jobs:
Read more at [Towncrier docs](https://towncrier.readthedocs.io/en/latest/quickstart.html#creating-news-fragments) Read more at [Towncrier docs](https://towncrier.readthedocs.io/en/latest/quickstart.html#creating-news-fragments)
- name: Create success comment - name: Changelog found
if: "success()" if: "success()"
uses: peter-evans/create-or-update-comment@v2 uses: peter-evans/create-or-update-comment@v2
with: with:
@ -69,8 +71,19 @@ jobs:
Thank you for adding a description of the changes Thank you for adding a description of the changes
skip-news:
runs-on: ubuntu-latest
if: "contains(github.event.pull_request.labels.*.name, 'skip news')"
steps:
- name: Find bot comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Changelog
- name: Comment when docs is not needed - name: Comment when docs is not needed
if: "contains(github.event.pull_request.labels.*.name, 'skip news')"
uses: peter-evans/create-or-update-comment@v2 uses: peter-evans/create-or-update-comment@v2
with: with:
edit-mode: replace edit-mode: replace
@ -79,4 +92,4 @@ jobs:
body: | body: |
# :corn: Changelog is not needed. # :corn: Changelog is not needed.
This PR does not require a changelog in due to the `skip news` label. This PR does not require a changelog because `skip news` label is present.