Skip to content

Commit

Permalink
retrieve PR info
Browse files Browse the repository at this point in the history
  • Loading branch information
aldousalvarez committed Jun 27, 2024
1 parent cc2f9c5 commit 52ab2d3
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
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/request-action@v2.x
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/request-action@v2.x
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: |
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 "PR description and commit messages do not match."
exit 1
else
echo "PR description and commit messages match."
fi

0 comments on commit 52ab2d3

Please sign in to comment.