-
Notifications
You must be signed in to change notification settings - Fork 9
146 lines (126 loc) Β· 5.53 KB
/
changelog-existence.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
---
name: π Changelog
on:
pull_request:
types: [opened, reopened, labeled, unlabeled, synchronize]
workflow_dispatch:
concurrency:
group: ${{ format('{0}-{1}-{2}-{3}-{4}', github.workflow, github.event_name, github.ref, github.base_ref || null, github.head_ref || null) }}
cancel-in-progress: true
permissions:
contents: read
issues: write
pull-requests: write
jobs:
changelog-existence:
name: π Check Changelog
if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip-changelog') && github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-24.04
steps:
- name: β€΅οΈ Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: βοΈ Check if changelog file was added
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: changelog_check
with:
filters: |
exists:
- added|modified: '.changes/unreleased/**.yaml'
- name: π§ Setup Go
if: steps.changelog_check.outputs.exists == 'true'
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: go.mod
cache: true
- name: π§ Setup Task
if: steps.changelog_check.outputs.exists == 'true'
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
repo-token: ${{ github.token }}
- name: π§ Setup Changie
if: steps.changelog_check.outputs.exists == 'true'
run: task install:changie
- name: π Find comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions[bot]
body-includes: "<!-- changelog -->"
- name: π Prepare comment (changelog)
if: steps.changelog_check.outputs.exists == 'true'
run: |
echo -e "# Changelog Preview\n" > changie.md
changie batch patch --dry-run --prerelease 'dev' >> changie.md
cat changie.md >> $GITHUB_STEP_SUMMARY
echo -e "\n<!-- changelog -->" >> changie.md
env:
CHANGIE_GITHUB_REPOSITORY: ${{ github.repository }}
- name: π Create comment (changelog)
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
if: steps.changelog_check.outputs.exists == 'true' && steps.fc.outputs.comment-id == ''
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: changie.md
- name: π Update comment (changelog)
if: steps.changelog_check.outputs.exists == 'true' && steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body-path: changie.md
edit-mode: replace
- name: π Prepare comment (missing)
if: steps.changelog_check.outputs.exists == 'false'
run: |
echo -e "# π Changelog entry required to merge\n" > changie.md
echo "Run \`changie new\` to add a new changelog entry" >> changie.md
cat changie.md >> $GITHUB_STEP_SUMMARY
echo -e "\n<!-- changelog -->" >> changie.md
- name: π Create comment (missing)
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
if: steps.changelog_check.outputs.exists == 'false' && steps.fc.outputs.comment-id == ''
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: changie.md
- name: π Update comment (missing)
if: steps.changelog_check.outputs.exists == 'false' && steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
body-path: changie.md
edit-mode: replace
- name: β
Pass if changelog entry exists
if: steps.changelog_check.outputs.exists == 'true'
run: |
echo "β
Changelog entry exists."
exit 0
- name: π Fail if changelog entry is missing and required
if: steps.changelog_check.outputs.exists == 'false'
run: |
echo "π Changelog entry required to merge."
exit 1
changelog-skip:
name: π Check Changelog
if: ${{ contains(github.event.pull_request.labels.*.name, 'skip-changelog') || github.actor == 'dependabot[bot]' }}
runs-on: ubuntu-24.04
steps:
- name: π Find comment
if: github.actor != 'dependabot[bot]'
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: github-actions[bot]
body-includes: "<!-- changelog -->"
- name: ποΈ Delete comment
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: github.actor != 'dependabot[bot]' && steps.fc.outputs.comment-id != ''
with:
script: |
github.rest.issues.deleteComment({
...context.repo,
comment_id: ${{ steps.fc.outputs.comment-id }},
});
- name: β
Pass (skip)
run: exit 0