Skip to content

feat(GAT-8233): DAR answer add new field #1649

feat(GAT-8233): DAR answer add new field

feat(GAT-8233): DAR answer add new field #1649

Workflow file for this run

name: PR Title Validation
on:
pull_request:
types: [opened, edited, synchronize]
jobs:
check-title:
runs-on: ubuntu-latest
steps:
- name: Check PR Title Format
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TITLE="${{ github.event.pull_request.title }}"
PR_NUMBER="${{ github.event.pull_request.number }}"
REPO="${{ github.repository }}"
echo "PR Title: $TITLE"
# Define regex patterns
RELEASE_PATTERN="^RELEASE: .+$"
STANDARD_PATTERN="^(feat|fix|chore|docs|style|refactor|test|perf)(!?)\(GAT-[0-9]+\): .+$"
if echo "$TITLE" | grep -E -q "$RELEASE_PATTERN"; then
echo "✅ PR title is a valid RELEASE PR!"
COMMENT="🎉 **Great job!** Your PR title follows the correct format for a release. 🚀"
elif echo "$TITLE" | grep -E -q "$STANDARD_PATTERN"; then
echo "✅ PR title is valid!"
COMMENT="🎉 **Great job!** Your PR title follows the correct format. 🚀"
else
echo "❌ Invalid PR title format!"
COMMENT="🚨 **Invalid PR title format!**\n\nYour PR title must follow one of these formats:\n- \`feat(GAT-1234): Your title\`\n- \`fix!(GAT-5678): Breaking change\`\n- \`RELEASE: vX.Y.Z\`\n\nPlease update your PR title accordingly. 😊"
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" \
-d "{\"body\": \"$COMMENT\"}"
exit 1
fi
# Check if an existing comment already exists
EXISTING_COMMENT=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" | jq -r '.[] | select(.body | contains("Great job!")) | .id')
if [[ -z "$EXISTING_COMMENT" ]]; then
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/$REPO/issues/$PR_NUMBER/comments" \
-d "{\"body\": \"$COMMENT\"}"
fi