-
Notifications
You must be signed in to change notification settings - Fork 405
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Internal] Add workflow to validate NEXT_CHANGELO.go updates
- Loading branch information
1 parent
3746ee4
commit 9b76bf8
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Check for NEXT_CHANGELOG.md Changes | ||
|
||
on: | ||
pull_request: # Trigger on pull request events | ||
|
||
jobs: | ||
check-next-changelog: | ||
runs-on: | ||
group: databricks-deco-testing-runner-group | ||
labels: ubuntu-latest-deco | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Fetch list of changed files | ||
id: changed-files | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Use the GitHub API to fetch changed files | ||
files=$(gh pr view ${{ github.event.pull_request.number }} --json files -q '.files[].path') | ||
# Sanitize to avoid code injection | ||
sanitized_files=$(echo "$files" | sed 's/[^a-zA-Z0-9._/-]/_/g') | ||
# Store the sanitized list of files in a temporary file to avoid env variable issues | ||
echo "$sanitized_files" > modified_files.txt | ||
- name: Fetch PR message | ||
id: pr-message | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Use the GitHub API to fetch the PR message | ||
pr_message=$(gh pr view ${{ github.event.pull_request.number }} --json body -q '.body') | ||
# Sanitize the PR message to avoid code injection, keeping the equal sign | ||
sanitized_pr_message=$(echo "$pr_message" | sed 's/[^a-zA-Z0-9._/-=]/_/g') | ||
# Store the sanitized PR message | ||
echo "$sanitized_pr_message" > pr_message.txt | ||
- name: Verify NEXT_CHANGELOG.md was modified or PR message contains NO_CHANGELOG=true | ||
run: | | ||
# Read the sanitized files and PR message from the temporary files | ||
modified_files=$(cat modified_files.txt) | ||
pr_message=$(cat pr_message.txt) | ||
# Check if NEXT_CHANGELOG.md exists in the list of changed files | ||
echo "Changed files: $modified_files" | ||
if ! echo "$modified_files" | grep -q "NEXT_CHANGELOG.md"; then | ||
echo "NEXT_CHANGELOG.md not modified." | ||
# Check if PR message contains NO_CHANGELOG=true | ||
echo "PR message: $pr_message" | ||
if echo "$pr_message" | grep -q "NO_CHANGELOG=true"; then | ||
echo "NO_CHANGELOG=true found in PR message. Skipping changelog check." | ||
exit 0 | ||
else | ||
echo "WARNING: file NEXT_CHANGELOG.md not changed. If this is expected, add NO_CHANGELOG=true to the PR message." | ||
exit 1 | ||
fi | ||
fi |