-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (86 loc) · 2.97 KB
/
changelog-changed.yml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This workflow ensures that a change was made to the changelog
---
name: Changelog Changed
run-name: >-
${{
format(
'{0} - Changelog Changed{1}',
github.event_name == 'pull_request'
&& format('PR#{0}{1}',github.event.number, github.event.pull_request.draft && ' [DRAFT]' || '')
|| format('Push [{0}]', github.ref_name),
github.event_name == 'pull_request'
&& format(' - [{0}-to-{1}]', github.event.pull_request.head.ref, github.event.pull_request.base.ref)
|| ''
)
}}
on:
pull_request:
branches:
- main
- develop
types:
- opened
- reopened
- synchronize
- ready_for_review
- labeled
- unlabeled
# Trigger if target branch was changed to a trunk
pull_request_target:
types:
- edited
branches:
- main
- develop
concurrency:
group: Changelog-${{ github.event.pull_request.head.ref }}-to-${{ github.event.pull_request.base.ref }}
cancel-in-progress: true
jobs:
checkForChangesToChangelog:
name: Changelog Changed
permissions:
contents: read # Read access to code and content in the repository
pull-requests: read # Read access to pull request metadata for the event
checks: write # Write access to report check results
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
steps:
# Checkout pull request branch
- name: ${{ format('Checkout [{0}]', github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name) }}
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.TJC_TOKEN || secrets.GITHUB_TOKEN }}
# Check for Changes in Changelog
# Or skip if there is no major, minor, or patch label
- name: Check for Changes to Changelog
id: getChanges
if: |
contains(github.event.label.name, 'major') ||
contains(github.event.label.name, 'minor') ||
contains(github.event.label.name, 'patch')
uses: tj-actions/changed-files@v45.0.4
with:
files: CHANGELOG.md
# Report Skipped
- name: Skipped - Version Not Changed
if: |
!contains(github.event.label.name, 'major') &&
!contains(github.event.label.name, 'minor') &&
!contains(github.event.label.name, 'patch')
uses: ./.github/actions/tools/annotation/notice
with:
message: "[Skipped] Version Not Changed"
# Report Success
- name: Success - Changelog Changed
if: steps.getChanges.outputs.any_modified == 'true'
uses: ./.github/actions/tools/annotation/notice
with:
message: "[Success] Changelog Changed"
# Report Failure
- name: Failure - Changelog Not Changed
if: steps.getChanges.outputs.any_modified == 'false'
uses: ./.github/actions/tools/exit-code
with:
code: 5
message: "Changelog Not Changed"