Skip to content

Commit 2d3df2b

Browse files
ci: workflow fails when feat, fix, or refactor PRs do not have changelog entry (#499)
* attempt fix * test * read granularity * remove all conditions * default af * some more * try this * making a change * ok this should make it pass * and if i change it back it should fail * remove all go code cahnges to see if wf passes * re adding go code changes should trigger it * only run on specific types of PRs * an update * revert that * when its edited too * revert go code change
1 parent e01cc50 commit 2d3df2b

File tree

2 files changed

+53
-19
lines changed

2 files changed

+53
-19
lines changed

.github/workflows/changelog.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on:
2+
pull_request:
3+
types: [ opened, synchronize, reopened, ready_for_review, edited ]
4+
paths: [ "**/*.go" ]
5+
name: Changelog Reminder
6+
jobs:
7+
remind:
8+
name: Changelog Reminder
9+
runs-on: ubuntu-latest
10+
if: ${{ !github.event.pull_request.draft }}
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Check PR title for semantic commit type
20+
run: |
21+
# Get the PR title
22+
PR_TITLE="${{ github.event.pull_request.title }}"
23+
echo "PR Title: $PR_TITLE"
24+
25+
# Check if PR title starts with feat, refactor, or fix
26+
if echo "$PR_TITLE" | grep -qE "^(feat|refactor|fix)(\(.+\))?!?:"; then
27+
echo "✅ PR title has relevant semantic commit type (feat, refactor, or fix)"
28+
echo "has_relevant_pr_title=true" >> $GITHUB_ENV
29+
else
30+
echo "ℹ️ PR title doesn't have relevant semantic commit type. Skipping changelog check."
31+
echo "has_relevant_pr_title=false" >> $GITHUB_ENV
32+
fi
33+
34+
- name: Check if CHANGELOG.md was modified
35+
if: env.has_relevant_pr_title == 'true'
36+
run: |
37+
# Get the list of changed files in this PR
38+
CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
39+
40+
# Check if CHANGELOG.md (case insensitive) is in the changed files
41+
if echo "$CHANGED_FILES" | grep -qi "changelog\.md"; then
42+
echo "✅ CHANGELOG.md has been modified in this PR"
43+
echo "changelog_modified=true" >> $GITHUB_ENV
44+
else
45+
echo "❌ CHANGELOG.md has not been modified in this PR"
46+
echo "changelog_modified=false" >> $GITHUB_ENV
47+
fi
48+
49+
- name: Fail if changelog not updated
50+
if: env.has_relevant_pr_title == 'true' && env.changelog_modified == 'false'
51+
run: |
52+
echo "::error::CHANGELOG.md must be updated for PRs with feat, refactor, or fix commits"
53+
exit 1

0 commit comments

Comments
 (0)