Skip to content

Commit

Permalink
Updating graphql for add_issue_to_project
Browse files Browse the repository at this point in the history
Restructuring queries to use ProjectV2
  • Loading branch information
laineyhm committed Jan 13, 2023
1 parent 5db9a73 commit 3ebca62
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions .github/workflows/set-backlog-fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Add Issue to Project

on:
issues:
types: [ opened ]
types: [ opened, reopened ]

jobs:
add_issue_to_project:
Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
repository(name:"web-languageforge", owner:$org) {
issue(number: $issue_number) {
id
projectNextItems(first:100) {
projectItems(first:100) {
nodes {
id
}
Expand All @@ -39,32 +39,35 @@ jobs:
}
}' -F issue_number=$ISSUE_NUMBER -f org=$ORGANIZATION > project_data.json
echo 'IN_PROJECT='$(jq '.data.repository.issue.projectNextItems[] | length' project_data.json) >> $GITHUB_ENV
echo 'IN_PROJECT='$(jq '.data.repository.issue.projectItems[] | length' project_data.json) >> $GITHUB_ENV
- name: get required info for set operations
env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ORGANIZATION: sillsdev
run: |
gh api graphql -f query='
query($org: String!) {
organization(login: $org){
projectNext(number: 1) {
query ($org: String!) {
organization(login: $org) {
projectV2(number: 1) {
id
fields(first:100) {
nodes {
field(name: "ProductOwner") {
... on ProjectV2SingleSelectField {
id
name
settings
options {
id
name
}
}
}
}
}
}' -f org=$ORGANIZATION > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "ProductOwner") | .id' project_data.json) >> $GITHUB_ENV
echo 'INCOMING_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "ProductOwner") | .settings | fromjson.options[] | select(.name=="Incoming") | .id' project_data.json) >> $GITHUB_ENV
echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'FIELD_ID='$(jq '.data.organization.projectV2.field.id' project_data.json) >> $GITHUB_ENV
echo 'INCOMING_ID='$(jq '.data.organization.projectV2.field.options[] | select(.name=="Incoming") | .id' project_data.json) >> $GITHUB_ENV
- name: Add issue to project
if: env.IN_PROJECT == 0
Expand All @@ -74,12 +77,12 @@ jobs:
run: |
item_id="$( gh api graphql -f query='
mutation($project:ID!, $item:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $item}) {
projectNextItem {
addProjectV2ItemById(input: {projectId: $project, contentId: $item}) {
item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
}' -f project=$PROJECT_ID -f item=$ISSUE_ID --jq '.data.addProjectV2ItemById.projectV2Item.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
Expand All @@ -95,13 +98,17 @@ jobs:
$field: ID!
$field_value: String!)
{
updateProjectNextItemField(input: {
updateProjectV2ItemFieldValue(input: {
projectId: $project
itemId: $item
fieldId: $field
value: $field_value})
value: {
singleSelectOptionId: $field_value
}
}
)
{
projectNextItem {
projectV2Item {
id
}
}
Expand Down

0 comments on commit 3ebca62

Please sign in to comment.