diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index f22f4fe9..9be23f7f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,31 +1,22 @@ + -### Description - +### Checklist -closes # (issue) - -### Documentation - -- [ ] I have updated the [CHANGELOG.md](/CHANGELOG.md), this is required for: - - Bug fixes (non-breaking change which fixes an issue) - - New features (non-breaking change which adds functionality) - - Breaking changes (fix or feature that would cause existing functionality to not work as expected) -- [ ] This change requires a documentation update - - [ ] I have made the corresponding changes to the documentation - -### Tests - -- [ ] I have added tests that prove my fix is effective or that my feature works + +- [ ] No CHANGELOG update needed + - [ ] No new tests needed + +- [ ] No documentation update needed diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000..7d42f3e5 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,40 @@ +name: changelog + +on: + # We need pull_request_target instead of pull_request because a write + # repository token is needed to add a review to a PR. DO NOT BUILD + # OR RUN UNTRUSTED CODE FROM PRs IN THIS ACTION + pull_request_target: + types: [opened, edited, synchronize] + +jobs: + check_changelog: + runs-on: ubuntu-20.04 + env: + NO_CHANGELOG: '[x] No CHANGELOG update needed' + steps: + - name: Get changed files + id: files + uses: Ana06/get-changed-files@v1.1 + - name: check changelog updated + id: changelog_updated + env: + PR_BODY: ${{ github.event.pull_request.body }} + FILES: ${{ steps.files.outputs.modified }} + run: | + echo $FILES | grep -qF 'CHANGELOG.md' || echo $PR_BODY | grep -qiF "$NO_CHANGELOG" + - name: Reject pull request if no CHANGELOG update + if: ${{ always() && steps.changelog_updated.outcome == 'failure' }} + uses: Ana06/automatic-pull-request-review@v0.1.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + event: REQUEST_CHANGES + body: "Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the `master (unreleased)` section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: `${{ env.NO_CHANGELOG }}`" + allow_duplicate: false + - name: Dismiss previous review if CHANGELOG update + uses: Ana06/automatic-pull-request-review@v0.1.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + event: DISMISS + body: "CHANGELOG updated or no update needed, thanks! :smile:" + diff --git a/CHANGELOG.md b/CHANGELOG.md index 599c42be..ee2b3eff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -117,6 +117,7 @@ It includes many new rules, including all new techniques introduced in MITRE ATT - ci, changelog: update `New Rules` section in CHANGELOG automatically https://github.com/fireeye/capa-rules/pull/374 #549 @Ana06 - ci, changelog: support multiple author in sync GH https://github.com/fireeye/capa-rules/pull/378 @Ana06 - ci, lint: check statements for single child statements #563 @mr-tz +- ci: reject PRs without CHANGELOG update to ensure CHANGELOG is kept up-to-date. #584 @Ana06 ### Raw diffs