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
51c8015c
Commit
51c8015c
authored
Jun 27, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
second part of workflow for project cards
parent
eb442a5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
4 deletions
+115
-4
label-released-issues.yml
.github/workflows/label-released-issues.yml
+0
-1
update-project-cards.yml
.github/workflows/update-project-cards.yml
+115
-3
No files found.
.github/workflows/label-released-issues.yml
View file @
51c8015c
name
:
Label released issues
name
:
Label released issues
on
:
on
:
pull_request
:
workflow_dispatch
:
workflow_dispatch
:
inputs
:
inputs
:
label_color
:
label_color
:
...
...
.github/workflows/update-project-cards.yml
View file @
51c8015c
...
@@ -57,14 +57,15 @@ jobs:
...
@@ -57,14 +57,15 @@ jobs:
runs-on
:
ubuntu-latest
runs-on
:
ubuntu-latest
steps
:
steps
:
-
name
:
Getting project info
-
name
:
Getting project info
id
:
project
id
:
project
_info
uses
:
actions/github-script@v6
uses
:
actions/github-script@v6
env
:
env
:
# remove fallbacks for PR trigger
#
TODO @tom2drum:
remove fallbacks for PR trigger
PROJECT_NAME
:
${{ github.event.pull_request && 'Front-end tasks' || github.event.inputs.project_name }}
PROJECT_NAME
:
${{ github.event.pull_request && 'Front-end tasks' || github.event.inputs.project_name }}
FIELD_NAME
:
${{ github.event.pull_request && 'Status' || github.event.inputs.field_name }}
FIELD_NAME
:
${{ github.event.pull_request && 'Status' || github.event.inputs.field_name }}
FIELD_VALUE
:
${{ github.event.pull_request && 'Released' || github.event.inputs.field_value }}
FIELD_VALUE
:
${{ github.event.pull_request && 'Released' || github.event.inputs.field_value }}
with
:
with
:
debug
:
true
script
:
|
script
:
|
const response = await github.graphql(`
const response = await github.graphql(`
query ($login: String!, $q: String!) {
query ($login: String!, $q: String!) {
...
@@ -137,4 +138,115 @@ jobs:
...
@@ -137,4 +138,115 @@ jobs:
core.setOutput('id', projectId);
core.setOutput('id', projectId);
core.setOutput('field_id', field.id);
core.setOutput('field_id', field.id);
core.setOutput('field_value_id', option.id);
core.setOutput('field_value_id', option.id);
\ No newline at end of file
-
name
:
Getting project items that linked to the issues
id
:
items
uses
:
actions/github-script@v6
env
:
# TODO @tom2drum: remove fallbacks for PR trigger
ISSUES
:
${{ github.event.pull_request && '[900,903,899,912]' || github.event.inputs.issues }}
with
:
debug
:
true
script
:
|
const result = [];
const issues = JSON.parse(process.env.ISSUES);
for (const issue of issues) {
const response = await getProjectItemId(issue);
response?.length > 0 && result.push(...response);
}
return result;
async function getProjectItemId(issueId) {
core.info(`Fetching project items for issue #${ issueId }...`);
try {
const response = await github.graphql(`
query ($owner: String!, $repo: String!, $id: Int!) {
repository(owner: $owner, name: $repo) {
issue(number: $id) {
title,
projectItems(first: 10) {
nodes {
id,
}
}
}
}
}
`,
{
owner: context.repo.owner,
repo: context.repo.repo,
id: issueId,
}
);
const { repository: { issue: { projectItems: { nodes: projectItems } } } } = response;
if (projectItems.length === 0) {
core.info('No project items found.\n');
return [];
}
const ids = projectItems.map((item) => item.id);
core.info(`Found [ ${ ids.join(', ') } ].\n`);
return ids;
} catch (error) {
if (error.status === 404) {
core.info('Nothing has found.\n');
return [];
}
}
}
-
name
:
Updating field value of the project items
id
:
updating_items
uses
:
actions/github-script@v6
env
:
ITEMS
:
${{ steps.items.outputs.result }}
PROJECT_ID
:
${{ steps.project_info.outputs.id }}
FIELD_ID
:
${{ steps.project_info.outputs.field_id }}
FIELD_VALUE_ID
:
${{ steps.project_info.outputs.field_value_id }}
with
:
debug
:
true
script
:
|
const items = JSON.parse(process.env.ITEMS);
if (items.length === 0) {
core.info('Nothing to update.');
core.notice('No project items found for provided issues. Nothing to update.');
return;
}
for (const item of items) {
core.info(`Changing field value for item ${ issue }...`);
await changeItemFieldValue(item);
core.info('Done.\n');
}
async function changeItemFieldValue(itemId) {
return await github.graphql(
`
mutation($input: UpdateProjectV2ItemFieldValueInput!) {
updateProjectV2ItemFieldValue(input: $input) {
clientMutationId
}
}
`,
{
input: {
projectId: process.env.PROJECT_ID,
fieldId: process.env.FIELD_ID,
itemId,
value: {
singleSelectOptionId: process.env.FIELD_VALUE_ID,
},
},
}
);
};
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