From 7ef0caf15d36d7f6040b3127e5f1e915f7d5ba5d Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 15:22:52 +0200 Subject: [PATCH 01/18] [Snyk] Check for snyk PRs --- .github/workflows/jira-pr-title.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 7fe3307..c494295 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: jobs: check-title: - runs-on: arc-runner-set + runs-on: ubuntu-latest steps: - name: Check PR title uses: actions/github-script@v7 @@ -31,8 +31,27 @@ jobs: } const prTitle = data.title - const jiraPattern = /[A-Z]+-\d+/g - if (!jiraPattern.test(prTitle)) { + + if (prTitle.includes('[Snyk]')) { + # label the PR with 'security' + const labels = ['security'] + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: data.number, + labels + }) + if (!jiraPattern.test(prTitle)) { + # add prefix '[PEAKON-2516]' to PR title + const newTitle = '[PEAKON-2516] ' + prTitle + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: data.number, + title: newTitle + }) + } + } else if (!jiraPattern.test(prTitle)) { core.setFailed('Cannot find a JIRA ticket in the PR title') } From cfc407e80fc86b55bee333295ca93124d7088413 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 15:30:01 +0200 Subject: [PATCH 02/18] try undo --- .github/workflows/jira-pr-title.yml | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index c494295..908358b 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -31,27 +31,8 @@ jobs: } const prTitle = data.title - const jiraPattern = /[A-Z]+-\d+/g - if (prTitle.includes('[Snyk]')) { - # label the PR with 'security' - const labels = ['security'] - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: data.number, - labels - }) - if (!jiraPattern.test(prTitle)) { - # add prefix '[PEAKON-2516]' to PR title - const newTitle = '[PEAKON-2516] ' + prTitle - await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: data.number, - title: newTitle - }) - } - } else if (!jiraPattern.test(prTitle)) { + const jiraPattern = /[A-Z]+-\d+/g + if (!jiraPattern.test(prTitle)) { core.setFailed('Cannot find a JIRA ticket in the PR title') } From 8c27d2e139323f758e712a32fb6e8772a39b4b54 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 15:40:26 +0200 Subject: [PATCH 03/18] Update pull request API request in jira-pr-title workflow --- .github/workflows/jira-pr-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 908358b..1ab9564 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -16,7 +16,7 @@ jobs: let data; try { - const result = await github.request('GET /repos/{owner}/{repo}/pulls/{pr}', { + const result = await github.request('GET /repos/peakon/.github/pulls/15', { owner: context.repo.owner, repo: context.repo.repo, pr: context.payload.pull_request.number From 825727ef64b6aebdac2b236b2b26bf24ba1ee911 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 15:42:18 +0200 Subject: [PATCH 04/18] Refactor pull request API request in jira-pr-title workflow for improved readability --- .github/workflows/jira-pr-title.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 1ab9564..dd63a1d 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -16,10 +16,10 @@ jobs: let data; try { - const result = await github.request('GET /repos/peakon/.github/pulls/15', { - owner: context.repo.owner, - repo: context.repo.repo, - pr: context.payload.pull_request.number + const result = await github.request('GET /repos/{owner}/{repo}/pulls/{pr}', { + owner: 'peakon', + repo: '.github', + pr: 15 }); data = result.data; From 9957fb84c719241c57b2c11635c010fc5bcb81ef Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 15:48:58 +0200 Subject: [PATCH 05/18] handle Snyk PRs --- .github/workflows/jira-pr-title.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index dd63a1d..3d07112 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -33,6 +33,26 @@ jobs: const prTitle = data.title const jiraPattern = /[A-Z]+-\d+/g - if (!jiraPattern.test(prTitle)) { - core.setFailed('Cannot find a JIRA ticket in the PR title') - } + + if (prTitle.includes('[Snyk]')) { + # label the PR with 'security' + const labels = ['security'] + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: data.number, + labels + }) + if (!jiraPattern.test(prTitle)) { + # add prefix '[PEAKON-2516]' to PR title + const newTitle = '[PEAKON-2516] ' + prTitle + await github.rest.pulls.update({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: data.number, + title: newTitle + }) + } + } else if (!jiraPattern.test(prTitle)) { + core.setFailed('Cannot find a JIRA ticket in the PR title') + } From b159773d8a9a0d2953601abe9f6c471521b0d183 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:26:57 +0200 Subject: [PATCH 06/18] Update jira-pr-title workflow to log actions and specify repository owner --- .github/workflows/jira-pr-title.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 3d07112..19afe2c 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -36,19 +36,21 @@ jobs: if (prTitle.includes('[Snyk]')) { # label the PR with 'security' + console.log('Labeling PR with security') const labels = ['security'] await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, + owner: 'peakon', // context.repo.owner, + repo: '.github', // context.repo.repo, issue_number: data.number, labels }) if (!jiraPattern.test(prTitle)) { + console.log('JIRA ticket not found in PR title') # add prefix '[PEAKON-2516]' to PR title const newTitle = '[PEAKON-2516] ' + prTitle await github.rest.pulls.update({ - owner: context.repo.owner, - repo: context.repo.repo, + owner: 'peakon', // context.repo.owner, + repo: '.github', // context.repo.repo, pull_number: data.number, title: newTitle }) From 1b17d83d5d15be9a87a11eae37e09204872fa16c Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:37:08 +0200 Subject: [PATCH 07/18] Try this --- .github/workflows/jira-pr-title.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 19afe2c..7e394b2 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -34,17 +34,18 @@ jobs: const jiraPattern = /[A-Z]+-\d+/g - if (prTitle.includes('[Snyk]')) { + + if (prTitle.includes('[Snyk]')) { # label the PR with 'security' console.log('Labeling PR with security') const labels = ['security'] - await github.rest.issues.addLabels({ + await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { owner: 'peakon', // context.repo.owner, repo: '.github', // context.repo.repo, issue_number: data.number, labels }) - if (!jiraPattern.test(prTitle)) { + /*if (!jiraPattern.test(prTitle)) { console.log('JIRA ticket not found in PR title') # add prefix '[PEAKON-2516]' to PR title const newTitle = '[PEAKON-2516] ' + prTitle @@ -54,7 +55,7 @@ jobs: pull_number: data.number, title: newTitle }) - } + }*/ } else if (!jiraPattern.test(prTitle)) { core.setFailed('Cannot find a JIRA ticket in the PR title') } From d0f04175a72908d2ad50f2b2393d95943354d123 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:38:13 +0200 Subject: [PATCH 08/18] Fix syntax error --- .github/workflows/jira-pr-title.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 7e394b2..b2c15ae 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -36,7 +36,7 @@ jobs: if (prTitle.includes('[Snyk]')) { - # label the PR with 'security' + // label the PR with 'security' console.log('Labeling PR with security') const labels = ['security'] await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { @@ -47,7 +47,7 @@ jobs: }) /*if (!jiraPattern.test(prTitle)) { console.log('JIRA ticket not found in PR title') - # add prefix '[PEAKON-2516]' to PR title + // add prefix '[PEAKON-2516]' to PR title const newTitle = '[PEAKON-2516] ' + prTitle await github.rest.pulls.update({ owner: 'peakon', // context.repo.owner, From 21bccb3a6199c4493e96726596d590579a702e53 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:43:24 +0200 Subject: [PATCH 09/18] next action --- .github/workflows/jira-pr-title.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index b2c15ae..dc2f917 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -36,8 +36,8 @@ jobs: if (prTitle.includes('[Snyk]')) { - // label the PR with 'security' - console.log('Labeling PR with security') + console.log('PR title contains [Snyk]') + console.log('1. Labeling PR with `security`') const labels = ['security'] await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { owner: 'peakon', // context.repo.owner, @@ -45,9 +45,8 @@ jobs: issue_number: data.number, labels }) - /*if (!jiraPattern.test(prTitle)) { - console.log('JIRA ticket not found in PR title') - // add prefix '[PEAKON-2516]' to PR title + if (!jiraPattern.test(prTitle)) { + console.log('2. Adding `[PEAKON-2516]` prefix to PR title') const newTitle = '[PEAKON-2516] ' + prTitle await github.rest.pulls.update({ owner: 'peakon', // context.repo.owner, @@ -55,7 +54,7 @@ jobs: pull_number: data.number, title: newTitle }) - }*/ + } } else if (!jiraPattern.test(prTitle)) { core.setFailed('Cannot find a JIRA ticket in the PR title') } From 560b01fec08b0b12151cff434c8c4b72b9d2e562 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:45:05 +0200 Subject: [PATCH 10/18] Fix this --- .github/workflows/jira-pr-title.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index dc2f917..84b6580 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -16,7 +16,7 @@ jobs: let data; try { - const result = await github.request('GET /repos/{owner}/{repo}/pulls/{pr}', { + const result = await github.rest.pulls.get({ owner: 'peakon', repo: '.github', pr: 15 @@ -39,7 +39,7 @@ jobs: console.log('PR title contains [Snyk]') console.log('1. Labeling PR with `security`') const labels = ['security'] - await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', { + await github.rest.issues.addLabels({ owner: 'peakon', // context.repo.owner, repo: '.github', // context.repo.repo, issue_number: data.number, From 3fd3ae835c26bffde31a934fc3525bbe02165b2e Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:46:55 +0200 Subject: [PATCH 11/18] Fix this --- .github/workflows/jira-pr-title.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 84b6580..0e5ebdb 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -17,10 +17,10 @@ jobs: try { const result = await github.rest.pulls.get({ - owner: 'peakon', - repo: '.github', - pr: 15 - }); + owner: 'peakon', //context.repo.owner, + repo: '.github', //context.repo.repo, + pull_number: 15 //context.issue.number + }) data = result.data; } catch (error) { From ba163590e8c454d535b2a3962613e560173f1ca7 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:56:44 +0200 Subject: [PATCH 12/18] Also add the label 'dependencies' --- .github/workflows/jira-pr-title.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 0e5ebdb..165787c 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -20,41 +20,41 @@ jobs: owner: 'peakon', //context.repo.owner, repo: '.github', //context.repo.repo, pull_number: 15 //context.issue.number - }) + }); data = result.data; } catch (error) { - const ip = await github.request('https://icanhazip.com') - console.log('IP Address: ', ip) + const ip = await github.request('https://icanhazip.com'); + console.log('IP Address: ', ip); throw error; } - const prTitle = data.title + const prTitle = data.title; - const jiraPattern = /[A-Z]+-\d+/g + const jiraPattern = /[A-Z]+-\d+/g; if (prTitle.includes('[Snyk]')) { - console.log('PR title contains [Snyk]') - console.log('1. Labeling PR with `security`') - const labels = ['security'] + console.log('PR title contains [Snyk]'); + console.log('1. Labeling PR with `depdependencies` and `security`'); + const labels = ['depdependencies', 'security']; await github.rest.issues.addLabels({ owner: 'peakon', // context.repo.owner, repo: '.github', // context.repo.repo, issue_number: data.number, labels - }) + }); if (!jiraPattern.test(prTitle)) { - console.log('2. Adding `[PEAKON-2516]` prefix to PR title') - const newTitle = '[PEAKON-2516] ' + prTitle + console.log('2. Adding `[PEAKON-2516]` prefix to PR title'); + const newTitle = `[PEAKON-2516] ${prTitle}`; await github.rest.pulls.update({ owner: 'peakon', // context.repo.owner, repo: '.github', // context.repo.repo, pull_number: data.number, title: newTitle - }) + }); } } else if (!jiraPattern.test(prTitle)) { - core.setFailed('Cannot find a JIRA ticket in the PR title') + core.setFailed('Cannot find a JIRA ticket in the PR title'); } From 48906d21ca650b082f88e527ec6d01539497b71d Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 16:58:57 +0200 Subject: [PATCH 13/18] typo --- .github/workflows/jira-pr-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 165787c..b66de4a 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -38,7 +38,7 @@ jobs: if (prTitle.includes('[Snyk]')) { console.log('PR title contains [Snyk]'); console.log('1. Labeling PR with `depdependencies` and `security`'); - const labels = ['depdependencies', 'security']; + const labels = ['dependencies', 'security']; await github.rest.issues.addLabels({ owner: 'peakon', // context.repo.owner, repo: '.github', // context.repo.repo, From 632f6044a5e29e67f2f4c612aa543b9cd78d4b1f Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 17:09:40 +0200 Subject: [PATCH 14/18] Add inputs to Jira PR title workflow and refactor pull request retrieval --- .github/workflows/jira-pr-title.yml | 54 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index b66de4a..84c12bd 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -3,6 +3,19 @@ on: pull_request: types: [opened, reopened, synchronize] workflow_dispatch: + inputs: + owner: + description: "Owner of the repository" + required: true + default: "peakon" + repo: + description: "Name of the repository" + required: true + default: ".github" + pull_number: + description: "Pull request number" + required: true + default: "1" jobs: check-title: runs-on: ubuntu-latest @@ -14,13 +27,13 @@ jobs: retries: 3 script: | let data; + const owner = context.payload.inputs?.owner || context.repo.owner; + const repo = context.payload.inputs?.repo || context.repo.repo; + const pull_number = context.payload.inputs?.pull_number || context.issue.number; + try { - const result = await github.rest.pulls.get({ - owner: 'peakon', //context.repo.owner, - repo: '.github', //context.repo.repo, - pull_number: 15 //context.issue.number - }); + const result = await github.rest.pulls.get({ owner, repo, pull_number }); data = result.data; } catch (error) { @@ -36,25 +49,16 @@ jobs: if (prTitle.includes('[Snyk]')) { - console.log('PR title contains [Snyk]'); - console.log('1. Labeling PR with `depdependencies` and `security`'); - const labels = ['dependencies', 'security']; - await github.rest.issues.addLabels({ - owner: 'peakon', // context.repo.owner, - repo: '.github', // context.repo.repo, - issue_number: data.number, - labels - }); - if (!jiraPattern.test(prTitle)) { - console.log('2. Adding `[PEAKON-2516]` prefix to PR title'); - const newTitle = `[PEAKON-2516] ${prTitle}`; - await github.rest.pulls.update({ - owner: 'peakon', // context.repo.owner, - repo: '.github', // context.repo.repo, - pull_number: data.number, - title: newTitle - }); - } + console.log('PR title contains [Snyk]'); + console.log('1. Labeling PR with `depdependencies` and `security`'); + const issue_number = data.number; + const labels = ['dependencies', 'security']; + await github.rest.issues.addLabels({owner, repo, issue_number, labels}); + if (!jiraPattern.test(prTitle)) { + console.log('2. Adding `[PEAKON-2516]` prefix to PR title'); + const title = `[PEAKON-2516] ${prTitle}`; + await github.rest.pulls.update({owener, repo, pull_number, title}); + } } else if (!jiraPattern.test(prTitle)) { - core.setFailed('Cannot find a JIRA ticket in the PR title'); + core.setFailed('Cannot find a JIRA ticket in the PR title'); } From 2881a862ef1ae4c161cb77dca5c8a932018f071d Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 17:23:00 +0200 Subject: [PATCH 15/18] Add runner input option to Jira PR title workflow --- .github/workflows/jira-pr-title.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 84c12bd..158f058 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -16,9 +16,19 @@ on: description: "Pull request number" required: true default: "1" + runner: + description: "Runner to use" + required: true + type: choice + options: + - "arc-runner-set" + - "ubuntu-latest" + - "windows-latest" + - "macos-latest" + default: "arc-runner-set" jobs: check-title: - runs-on: ubuntu-latest + runs-on: ${{ github.event.inputs.runner }} steps: - name: Check PR title uses: actions/github-script@v7 From 1ba20d5dc50d44c0e2e95115032e7eba838edd1b Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 17:41:52 +0200 Subject: [PATCH 16/18] Set default runner for Jira PR title workflows --- .github/workflows/jira-pr-title-tmp.yml | 2 +- .github/workflows/jira-pr-title.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jira-pr-title-tmp.yml b/.github/workflows/jira-pr-title-tmp.yml index eb91102..bdb495d 100644 --- a/.github/workflows/jira-pr-title-tmp.yml +++ b/.github/workflows/jira-pr-title-tmp.yml @@ -26,7 +26,7 @@ on: default: "arc-runner-set" jobs: check-title: - runs-on: ${{ github.event.inputs.runner }} + runs-on: ${{ github.event.inputs.runner || 'arc-runner-set' }} steps: - name: Check PR title uses: actions/github-script@v7 diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index 158f058..faec706 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -28,7 +28,7 @@ on: default: "arc-runner-set" jobs: check-title: - runs-on: ${{ github.event.inputs.runner }} + runs-on: ${{ github.event.inputs.runner || 'arc-runner-set' }} steps: - name: Check PR title uses: actions/github-script@v7 From 43f202f588797c61fdb4e47fc22dad3ab18b8a65 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 17:44:13 +0200 Subject: [PATCH 17/18] Remove temporary Jira PR title check workflow --- .github/workflows/jira-pr-title-tmp.yml | 72 ------------------------- 1 file changed, 72 deletions(-) delete mode 100644 .github/workflows/jira-pr-title-tmp.yml diff --git a/.github/workflows/jira-pr-title-tmp.yml b/.github/workflows/jira-pr-title-tmp.yml deleted file mode 100644 index bdb495d..0000000 --- a/.github/workflows/jira-pr-title-tmp.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: "Jira PR Title Check - Temporary" -on: - workflow_dispatch: - inputs: - owner: - description: "Owner of the repository" - required: true - default: "peakon" - repo: - description: "Name of the repository" - required: true - default: ".github" - pull_number: - description: "Pull request number" - required: true - default: "1" - runner: - description: "Runner to use" - required: true - type: choice - options: - - "arc-runner-set" - - "ubuntu-latest" - - "windows-latest" - - "macos-latest" - default: "arc-runner-set" -jobs: - check-title: - runs-on: ${{ github.event.inputs.runner || 'arc-runner-set' }} - steps: - - name: Check PR title - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - retries: 3 - script: | - let data; - const owner = context.payload.inputs?.owner || context.repo.owner; - const repo = context.payload.inputs?.repo || context.repo.repo; - const pull_number = context.payload.inputs?.pull_number || context.issue.number; - - - try { - const result = await github.rest.pulls.get({ owner, repo, pull_number }); - - data = result.data; - } catch (error) { - const ip = await github.request('https://icanhazip.com'); - console.log('IP Address: ', ip); - - throw error; - } - - const prTitle = data.title; - - const jiraPattern = /[A-Z]+-\d+/g; - - - if (prTitle.includes('[Snyk]')) { - console.log('PR title contains [Snyk]'); - console.log('1. Labeling PR with `depdependencies` and `security`'); - const issue_number = data.number; - const labels = ['dependencies', 'security']; - await github.rest.issues.addLabels({owner, repo, issue_number, labels}); - if (!jiraPattern.test(prTitle)) { - console.log('2. Adding `[PEAKON-2516]` prefix to PR title'); - const title = `[PEAKON-2516] ${prTitle}`; - await github.rest.pulls.update({owener, repo, pull_number, title}); - } - } else if (!jiraPattern.test(prTitle)) { - core.setFailed('Cannot find a JIRA ticket in the PR title'); - } From 2eff3639d07d990c9904affff750429bcbf08256 Mon Sep 17 00:00:00 2001 From: Payman Delshad Date: Thu, 3 Apr 2025 17:48:47 +0200 Subject: [PATCH 18/18] Fix runner input handling in Jira PR title workflow --- .github/workflows/jira-pr-title.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira-pr-title.yml b/.github/workflows/jira-pr-title.yml index faec706..d397cc1 100644 --- a/.github/workflows/jira-pr-title.yml +++ b/.github/workflows/jira-pr-title.yml @@ -28,7 +28,7 @@ on: default: "arc-runner-set" jobs: check-title: - runs-on: ${{ github.event.inputs.runner || 'arc-runner-set' }} + runs-on: ${{ github.event.inputs && github.event.inputs.runner || 'arc-runner-set' }} steps: - name: Check PR title uses: actions/github-script@v7