github.com/status-im/status-go@v1.1.0/.github/workflows/commit-check.yml (about) 1 name: "Conventional Commits" 2 3 on: 4 pull_request: 5 types: 6 - opened 7 - synchronize 8 jobs: 9 main: 10 name: Validate format 11 runs-on: ubuntu-latest 12 permissions: 13 pull-requests: write 14 steps: 15 - uses: actions/checkout@v4 16 with: 17 ref: ${{ env.GITHUB_HEAD_REF }} 18 fetch-tags: true 19 20 - name: Fetch tags 21 run: | 22 git fetch --tags --quiet 23 git checkout origin/${GITHUB_HEAD_REF} 24 25 - name: Check commit message 26 id: check_commit_message 27 run: | 28 set +e 29 30 output=$(./_assets/scripts/commit_check.sh 2>&1) 31 exit_code=$? 32 33 echo "${output}" | sed '$d' 34 echo "has_breaking_changes=${has_breaking_changes}" 35 36 echo "exit_code=${exit_code}" >> $GITHUB_OUTPUT 37 38 has_breaking_changes=$(echo "${output}" | tail -n 1) 39 echo "has_breaking_changes=${has_breaking_changes}" >> $GITHUB_OUTPUT 40 41 invalid_commit_messages=$(echo "${output}" | sed '1d;$d') 42 invalid_commit_messages=$(echo "${output}" | sed '1d;$d') 43 invalid_commit_messages=$(echo "${invalid_commit_messages}" | sed 's/\x1b\[[0-9;]*m//g') # Remove color codes 44 invalid_commit_messages=$(echo "${invalid_commit_messages}" | sed 's/^Commit message is ill-formed: //') # Remove prefix 45 46 if [[ $exit_code -ne 0 ]]; then 47 EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) 48 echo "error_message<<$EOF" >> "$GITHUB_ENV" 49 echo "${invalid_commit_messages}" >> "$GITHUB_ENV" 50 echo "$EOF" >> "$GITHUB_ENV" 51 52 fi 53 54 - name: "Publish failed commit messages" 55 uses: marocchino/sticky-pull-request-comment@v2 56 # When the previous steps fails, the workflow would stop. By adding this 57 # condition you can continue the execution with the populated error message. 58 if: always() && (steps.check_commit_message.outputs.exit_code != 0) 59 with: 60 header: commit-message-lint-error 61 message: | 62 We require commits to follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/), but with `_` for non-breaking changes. 63 Please fix these commit messages: 64 ``` 65 ${{ env.error_message }} 66 ``` 67 68 - name: "Publish breaking changes message" 69 uses: marocchino/sticky-pull-request-comment@v2 70 # When the previous steps fails, the workflow would stop. By adding this 71 # condition you can continue the execution with the populated error message. 72 if: always() && (steps.check_commit_message.outputs.exit_code == 0 && steps.check_commit_message.outputs.has_breaking_changes == 'true') 73 with: 74 header: commit-message-lint-error 75 message: | 76 Looks like you have BREAKING CHANGES in your PR. 77 Please make sure to follow [💔How to introduce breaking changes](https://www.notion.so/How-to-introduce-breaking-changes-ded9ec2d91464a46a2593c0d8de62fbe?pvs=4) guide: 78 79 ### Check-list 80 81 - [ ] Tried to avoid this breaking change 82 - [ ] Updated [status-desktop](https://github.com/status-im/status-desktop) 83 - [ ] Updated [status-mobile](https://github.com/status-im/status-mobile) 84 85 # Delete a previous comment when the issue has been resolved 86 - name: "Delete previous comment" 87 if: ${{ steps.check_commit_message.outputs.exit_code == 0 && steps.check_commit_message.outputs.has_breaking_changes == 'false' }} 88 uses: marocchino/sticky-pull-request-comment@v2 89 with: 90 header: commit-message-lint-error 91 delete: true 92 93 - name: "Mark as failed" 94 if: steps.check_commit_message.outputs.exit_code != 0 95 uses: actions/github-script@v7 96 with: 97 script: | 98 core.setFailed("Some commit messages are ill-formed") 99 100 - name: "Update breaking changes label" 101 if: always() 102 run: | 103 if [[ $ADD_LABEL == 'true' ]]; then 104 command="--add-label" 105 else 106 command="--remove-label" 107 fi 108 gh issue edit "$NUMBER" $command "breaking change" 109 env: 110 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 111 GH_REPO: ${{ github.repository }} 112 NUMBER: ${{ github.event.pull_request.number }} 113 ADD_LABEL: ${{ steps.check_commit_message.outputs.has_breaking_changes == 'true' }}