forked from hyperledger-cacti/cacti
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc2f9c5
commit cf7d6f3
Showing
1 changed file
with
49 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Check PR Description and Commit Message Parity | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize] | ||
|
||
jobs: | ||
check-parity: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get PR Information | ||
id: get_pr | ||
uses: octokit/[email protected] | ||
with: | ||
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get Commit Messages | ||
id: get_commits | ||
uses: octokit/[email protected] | ||
with: | ||
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Check PR Description and Commit Messages | ||
id: check_parity | ||
run: | | ||
Check failure on line 33 in .github/workflows/pull-request.yaml GitHub Actions / ActionLint / Lint_GitHub_Actions
Check failure on line 33 in .github/workflows/pull-request.yaml GitHub Actions / ActionLint / Lint_GitHub_Actions
|
||
pr_body='${{ steps.get_pr.outputs.data }}' | ||
commits='${{ steps.get_commits.outputs.data }}' | ||
pr_description=$(echo "$pr_body" | jq -r .body) | ||
commit_messages=$(echo "$commits" | jq -r '.[].commit.message' | tr '\n' ' ') | ||
if [[ "$pr_description" != "$commit_messages" ]]; then | ||
echo "::set-output name=parity_check::fail" | ||
exit 1 | ||
else | ||
echo "::set-output name=parity_check::pass" | ||
fi | ||
- name: Set Failure if Parity Check Failed | ||
if: steps.check_parity.outputs.parity_check == 'fail' | ||
run: exit 1 |