Skip to content

Commit

Permalink
ci: fix changelog script
Browse files Browse the repository at this point in the history
  • Loading branch information
Fraccaman committed Jul 26, 2024
1 parent 9b8252e commit 18fe87d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
fetch-depth: 0
- name: Check changelog
run: bash .github/workflows/scripts/check-changelog.sh
env:
SHA: ${{ github.sha }}

lints:
container:
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/scripts/check-changelog.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
#!/bin/bash

check_changelog_added_in_subfolders() {
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ -z "${SHA}" ]]; then
head_commit=$(git rev-parse HEAD)
else
head_commit="${SHA}"
fi
echo "Using sha: $head_commit"

subfolders=("ci" "bug-fixes" "improvements" "miscellaneous" "features" "testing" "docs")

subfolder_pattern=$(printf "|%s" "${subfolders[@]}")
subfolder_pattern=${subfolder_pattern:1} # Remove the leading '|'

added_files=$(git diff --diff-filter=A --name-only "main..$current_branch" | grep "\.changelog/")
added_files=$(git diff --diff-filter=A --name-only "main..$head_commit" | grep "\.changelog/")

relevant_files=$(echo "$added_files" | grep -E "\.changelog/unreleased/($subfolder_pattern)/")

if [ -n "$relevant_files" ]; then
echo "Changelog found: $relevant_files"
exit 0
else
echo "No files were added in the .changelog directory in the specified subfolders."
exit 1
fi
}

Expand Down

0 comments on commit 18fe87d

Please sign in to comment.