-
Notifications
You must be signed in to change notification settings - Fork 4
50 lines (44 loc) · 1.78 KB
/
Copy pathchangelog.yml
File metadata and controls
50 lines (44 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Inspired by the changelog-check-action (https://github.com/tarides/changelog-check-action)
name: Check Changelog
on:
pull_request:
# opened/synchronize/reopened: Check changelog when PR is created or updated
# labeled/unlabeled: Re-run check when "no changelog" label is added/removed
types: [opened, synchronize, reopened, labeled, unlabeled]
branches: [develop, main]
permissions: {}
concurrency:
# Cancel existing job(s) for workflow when a new one is queued
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CHANGELOG: CHANGELOG.md
BASE_REF: ${{ github.base_ref }}
# Has no changelog label
HAS_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'no changelog') }}
jobs:
check-changelog:
name: Verify Changelog Updated
runs-on: ubuntu-latest
# For labeled/unlabeled actions, only run if it involves the "no changelog" label
if: >
(contains(github.event.action, 'label') && github.event.label.name == 'no changelog')
|| ! contains(github.event.action, 'label')
steps:
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
fetch-depth: 0
- name: Check changelog
run: |
if ${HAS_LABEL}; then
echo "Check passes, since 'no changelog' label is set"
exit 0
elif git diff --exit-code "origin/${BASE_REF}" -- "${CHANGELOG}"; then
echo "Error: User-visible changes should come with an entry in the changelog."
echo "For changes not user-visible, add the 'no changelog' label to override this behavior."
exit 1
else
echo "Check passes, changes detected in ${CHANGELOG}"
fi