From 5158690d7bbc75889038709d561266059664a45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randi=20=C3=98yri?= Date: Thu, 1 Jun 2023 12:18:08 +0200 Subject: [PATCH 1/3] Update find-jira-id.yml --- .github/workflows/find-jira-id.yml | 52 ++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/.github/workflows/find-jira-id.yml b/.github/workflows/find-jira-id.yml index adebbb7..afa13b0 100644 --- a/.github/workflows/find-jira-id.yml +++ b/.github/workflows/find-jira-id.yml @@ -16,14 +16,52 @@ jobs: if: ${{ github.event_name == 'pull_request'}} runs-on: ubuntu-latest steps: - - uses: deepakputhraya/action-pr-title@v1.0.2 + - uses: actions/github-script@v6 with: - regex: '(\w)+(\s\w)*' # Regex the title should match. - allowed_prefixes: 'Bump,ID-,MINID-,PBLEID-,MP-,KRR-,PF-,AOS-' # title should start with the given prefix - prefix_case_sensitive: false # title prefix are case insensitive - min_length: 10 # Min length of the title - max_length: 100 # Max length of the title - github_token: ${{ github.token }} # Default: ${{ github.token }} + script: | + const REGEX = new RegExp("^[^…]+$"); // Title must match this regex + const MIN_LENGTH = 10; // Min length of the title + const MAX_LENGTH = 100; // Max length of the title (-1 is no max) + const ALLOWED_PREFIXES = ['Bump','ID-','MIN-','PBLEID-','MP-','KRR-','PF-','AOS-','SP-']; // Title must start with one of these prefixes + const PREFIX_CASE_SENSITIVE = false; // Whether the prefix is case sensitive + + const validateTitlePrefix = (title, prefix) => + PREFIX_CASE_SENSITIVE + ? title.startsWith(prefix) + : title.toLowerCase().startsWith(prefix.toLowerCase()); + + const { title } = context.payload.pull_request; + if (!REGEX.test(title)) { + core.setFailed( + `Pull Request title "${title}" failed to match regex - ${REGEX}` + ); + return; + } + + if (title.length < MIN_LENGTH) { + core.setFailed( + `Pull Request title "${title}" is smaller than the minimum length - ${MIN_LENGTH}` + ); + return; + } + + if (MAX_LENGTH > 0 && title.length > MAX_LENGTH) { + core.setFailed( + `Pull Request title "${title}" is greater than the maximum length - ${MAX_LENGTH}` + ); + return; + } + + core.info(`Allowed Prefixes: ${ALLOWED_PREFIXES}`); + if ( + ALLOWED_PREFIXES.length && + !ALLOWED_PREFIXES.some((prefix) => validateTitlePrefix(title, prefix)) + ) { + core.setFailed( + `Pull Request title "${title}" did not start with any of the required prefixes - ${ALLOWED_PREFIXES}` + ); + return; + } find-jira-id: runs-on: ubuntu-latest steps: From 5082da477d3c262f089c99813f2c1871e4694532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randi=20=C3=98yri?= Date: Thu, 1 Jun 2023 12:20:18 +0200 Subject: [PATCH 2/3] Update find-jira-id.yml --- .github/workflows/find-jira-id.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/find-jira-id.yml b/.github/workflows/find-jira-id.yml index afa13b0..9706589 100644 --- a/.github/workflows/find-jira-id.yml +++ b/.github/workflows/find-jira-id.yml @@ -2,7 +2,6 @@ name: Has jira-id on: push: - branches: [ main ] jobs: dumpcontext: From 683cc963adebfbab97764adb5fb7f8e9bd83f689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Randi=20=C3=98yri?= Date: Thu, 1 Jun 2023 12:22:28 +0200 Subject: [PATCH 3/3] Update find-jira-id.yml --- .github/workflows/find-jira-id.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/find-jira-id.yml b/.github/workflows/find-jira-id.yml index 9706589..282c55e 100644 --- a/.github/workflows/find-jira-id.yml +++ b/.github/workflows/find-jira-id.yml @@ -12,7 +12,7 @@ jobs: GITHUB_CONTEXT: ${{ toJSON(github) }} run: echo "$GITHUB_CONTEXT" verify-pull-request-title: - if: ${{ github.event_name == 'pull_request'}} + #if: ${{ github.event_name == 'pull_request'}} runs-on: ubuntu-latest steps: - uses: actions/github-script@v6