From a0ba858d752b76de26d673ef9894c66e76cf58a3 Mon Sep 17 00:00:00 2001 From: sarahCx Date: Wed, 18 Sep 2024 16:08:02 +0300 Subject: [PATCH] check requirement --- .github/workflows/pr-linter.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/pr-linter.yml diff --git a/.github/workflows/pr-linter.yml b/.github/workflows/pr-linter.yml new file mode 100644 index 000000000..ec5bf2ee6 --- /dev/null +++ b/.github/workflows/pr-linter.yml @@ -0,0 +1,31 @@ +name: PR Linter + +on: + pull_request: + types: [opened, edited] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Check PR Title and Branch + run: | + PR_TITLE="${{ github.event.pull_request.title }}" + PR_BRANCH="${{ github.head_ref }}" + + if ! [[ "$PR_TITLE" =~ ^[A-Z][a-zA-Z0-9]* ]]; then + echo "::error::PR title must be in CamelCase. Please update the title." + exit 1 + fi + + if ! [[ "$PR_TITLE" =~ \(AST-[0-9]+\)$ ]]; then + echo "::error::PR title must contain a Jira ticket ID at the end in the format '(AST-XXXX)'." + exit 1 + fi + + if ! [[ "$PR_BRANCH" =~ ^(bug|feature)/ ]]; then + echo "::error::Branch name must start with 'bug/' or 'feature/'." + exit 1 + fi + + shell: bash \ No newline at end of file