Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions .github/workflows/jira-pr-title-tmp.yml

This file was deleted.

62 changes: 49 additions & 13 deletions .github/workflows/jira-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,32 @@ 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"
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: 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
Expand All @@ -14,25 +37,38 @@ 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.request('GET /repos/{owner}/{repo}/pulls/{pr}', {
owner: context.repo.owner,
repo: context.repo.repo,
pr: context.payload.pull_request.number
});
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)
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
if (!jiraPattern.test(prTitle)) {
core.setFailed('Cannot find a JIRA ticket in the PR 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');
}
Loading