Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/sbhan #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR Title and Description Check

on:
pull_request:
types: [opened, edited, synchronize] # Trigger on PR creation, edits, or updates

jobs:
check-pr:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up GitHub CLI
uses: cli/cli-action@v2
with:
version: latest

- name: Fetch PR details
id: fetch_pr
run: |
# Use GitHub CLI to get PR details
pr_title=$(gh pr view ${{ github.event.pull_request.number }} --json title -q ".title")
pr_body=$(gh pr view ${{ github.event.pull_request.number }} --json body -q ".body")
echo "PR_TITLE=${pr_title}" >> $GITHUB_ENV
echo "PR_BODY=${pr_body}" >> $GITHUB_ENV

- name: Validate PR Title
run: |
echo "Validating PR Title: $PR_TITLE"
if [[ ! "$PR_TITLE" =~ ^(feat|fix|docs|style|refactor|test): ]]; then
echo "Error: PR title does not start with a required type (feat, fix, docs, style, refactor, test)."
exit 1
fi

- name: Validate PR Description
run: |
echo "Validating PR Description."
if [[ -z "$PR_BODY" ]]; then
echo "Error: PR description is missing."
exit 1
fi