Skip to content

Commit

Permalink
Fix BREAKING_CHANGE string detection in commit msg / PR body
Browse files Browse the repository at this point in the history
BREAKING_CHANGE
  • Loading branch information
hubcio committed Mar 2, 2024
1 parent 90e6034 commit 94a7989
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/backwards_compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,43 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Print the event payload
run: cat "$GITHUB_EVENT_PATH"

- name: Check for BREAKING_CHANGE in commit message
id: check_commit
run: |
COMMIT_MSG=$(git log --format=%B -n 1 HEAD)
echo "Commit message: $COMMIT_MSG"
if echo "$COMMIT_MSG" | grep -q "BREAKING_CHANGE"; then
BREAKING_CHANGE_FOUND=false
for COMMIT in $(git log --format=%H HEAD^..HEAD); do
COMMIT_MSG=$(git log --format=%B -n 1 $COMMIT)
echo "Commit message: $COMMIT_MSG"
if echo "$COMMIT_MSG" | grep -q "BREAKING_CHANGE"; then
BREAKING_CHANGE_FOUND=true
break
fi
done
if $BREAKING_CHANGE_FOUND; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "skip=true, 'BREAKING_CHANGE' found in commit message"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "skip=false, 'BREAKING_CHANGE' not found in commit message"
fi
- name: Check for BREAKING_CHANGE in pull request body
id: check_pr_body
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_MSG_TITLE=$(jq -r .pull_request.title "$GITHUB_EVENT_PATH")
PR_MSG_BODY=$(jq -r .pull_request.body "$GITHUB_EVENT_PATH")
PR_MSG_BODY=${{ github.event.pull_request.body }}
echo "Pull Request body: $PR_MSG_BODY"
if [[ "$PR_MSG_BODY" == *"BREAKING_CHANGE"* ]]; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "skip=true, 'BREAKING_CHANGE' found in pull request body"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "skip=false, 'BREAKING_CHANGE' not found in pull request body"
fi
build_and_test:
Expand All @@ -44,6 +58,8 @@ jobs:
if: ${{ needs.check_commit_message.outputs.should_skip != 'true' }}
steps:
- run: echo "${{ needs.check_commit_message.outputs.should_skip }}"
- run: echo "${{ needs.check_commit_message.outputs.should_skip }}"
- run: echo "${{ needs.check_commit_message.outputs.should_skip }}"

- uses: actions/checkout@v4
with:
Expand Down

0 comments on commit 94a7989

Please sign in to comment.