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 cf7d6f3
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/pull-request.yaml
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

View workflow job for this annotation

GitHub Actions / ActionLint / Lint_GitHub_Actions

workflow command "set-output" was deprecated. use `echo "{name}={value}" >> $GITHUB_OUTPUT` instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

Check failure on line 33 in .github/workflows/pull-request.yaml

View workflow job for this annotation

GitHub Actions / ActionLint / Lint_GitHub_Actions

workflow command "set-output" was deprecated. use `echo "{name}={value}" >> $GITHUB_OUTPUT` instead: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-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

0 comments on commit cf7d6f3

Please sign in to comment.