From a60a5cb3b7baff1da54ed2e7e8fc68eabf82c331 Mon Sep 17 00:00:00 2001 From: sanjay2806-max Date: Fri, 9 Aug 2024 19:37:42 +0530 Subject: [PATCH 1/2] Create github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1 @@ + From 776645a5084764b8e1eb39b26a55a85c56b0e3c6 Mon Sep 17 00:00:00 2001 From: Sanjay Date: Sat, 10 Aug 2024 01:19:09 +0530 Subject: [PATCH 2/2] Update github-actions-demo.yml --- .github/workflows/github-actions-demo.yml | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 8b137891..fbe9f0a0 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1 +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