Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
11b723f0
Commit
11b723f0
authored
May 10, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[skip ci] workflow for copying labels to pr
parent
4b906f03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
120 additions
and
5 deletions
+120
-5
copy-issues-labels.yml
.github/workflows/copy-issues-labels.yml
+105
-0
project-management.yml
.github/workflows/project-management.yml
+15
-5
No files found.
.github/workflows/copy-issues-labels.yml
0 → 100644
View file @
11b723f0
name
:
Copy issues labels to pull request
on
:
workflow_dispatch
:
inputs
:
pr_number
:
description
:
Pull request number
required
:
true
type
:
string
issues
:
description
:
JSON encoded list of issue ids
required
:
true
type
:
string
jobs
:
run
:
name
:
Run
runs-on
:
ubuntu-latest
steps
:
-
name
:
Find unique labels
id
:
find_unique_labels
uses
:
actions/github-script@v7
env
:
ISSUES
:
${{ inputs.issues }}
with
:
script
:
|
const issues = JSON.parse(process.env.ISSUES);
const WHITE_LISTED_LABELS = [
'client feature',
'feature',
'bug',
'dependencies',
'performance',
'chore',
'enhancement',
'refactoring',
'tech',
]
const labels = await Promise.all(issues.map(getIssueLabels));
const uniqueLabels = uniqueStringArray(labels.flat().filter((label) => WHITE_LISTED_LABELS.includes(label)));
if (uniqueLabels.length === 0) {
core.info('No labels found.\n');
return [];
}
core.info(`Found following labels: ${ uniqueLabels.join(', ') }.\n`);
return uniqueLabels;
async function getIssueLabels(issue) {
core.info(`Obtaining labels list for the issue #${ issue }...`);
try {
const response = await octokit.request('GET /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: 'blockscout',
repo: 'frontend',
issue_number: issue,
});
return response.data.map(({ name }) => name);
} catch (error) {
core.error(`Failed to obtain labels for the issue #${ issue }: ${ error.message }`);
return [];
}
}
function uniqueStringArray(array) {
return Array.from(new Set(array));
}
-
name
:
Update pull request labels
id
:
update_pr_labels
uses
:
actions/github-script@v7
env
:
LABELS
:
${{ steps.find_unique_labels.outputs.result }}
PR_NUMBER
:
${{ inputs.pr_number }}
with
:
script
:
|
const labels = JSON.parse(process.env.LABELS);
const prNumber = Number(process.env.PR_NUMBER);
if (labels.length === 0) {
core.info('Nothing to update.\n');
return;
}
for (const label of labels) {
await addLabelToPr(prNumber, label);
}
core.info('Done.\n');
async function addLabelToPr(prNumber, label) {
console.log(`Adding label to the pull request #${ prNumber }...`);
return await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/labels', {
owner: 'blockscout',
repo: 'frontend',
issue_number: prNumber,
labels: [ label ],
});
}
\ No newline at end of file
.github/workflows/project-management.yml
View file @
11b723f0
...
@@ -28,7 +28,7 @@ jobs:
...
@@ -28,7 +28,7 @@ jobs:
issues
:
"
[${{
github.event.issue.number
}}]"
issues
:
"
[${{
github.event.issue.number
}}]"
secrets
:
inherit
secrets
:
inherit
review_request
ed_issues
:
pr_link
ed_issues
:
name
:
Get issues linked to PR
name
:
Get issues linked to PR
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
if
:
${{ github.event.pull_request && github.event.action == 'review_requested' }}
if
:
${{ github.event.pull_request && github.event.action == 'review_requested' }}
...
@@ -76,14 +76,24 @@ jobs:
...
@@ -76,14 +76,24 @@ jobs:
return issues;
return issues;
review_requested_tasks
:
issues_in_review
:
name
:
Update status for issues in review
name
:
Update status for issues in review
needs
:
[
review_request
ed_issues
]
needs
:
[
pr_link
ed_issues
]
if
:
${{ needs.
review_request
ed_issues.outputs.issues }}
if
:
${{ needs.
pr_link
ed_issues.outputs.issues }}
uses
:
'
./.github/workflows/update-project-cards.yml'
uses
:
'
./.github/workflows/update-project-cards.yml'
secrets
:
inherit
secrets
:
inherit
with
:
with
:
project_name
:
${{ vars.PROJECT_NAME }}
project_name
:
${{ vars.PROJECT_NAME }}
field_name
:
Status
field_name
:
Status
field_value
:
Review
field_value
:
Review
issues
:
${{ needs.review_requested_issues.outputs.issues }}
issues
:
${{ needs.pr_linked_issues.outputs.issues }}
copy_labels
:
name
:
Copy issues labels to pull request
needs
:
[
pr_linked_issues
]
if
:
${{ needs.pr_linked_issues.outputs.issues }}
uses
:
'
./.github/workflows/copy-issues-labels.yml'
secrets
:
inherit
with
:
pr_number
:
${{ github.event.pull_request.number }}
issues
:
${{ needs.pr_linked_issues.outputs.issues }}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment