Skip to content

Commit

Permalink
chore: update graphql to projectV2 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas authored Jan 26, 2023
1 parent 19d2fba commit 40f5f75
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Project Board Automation'
description: 'Automate GitHub Projects with ease'
name: "Project Board Automation"
description: "Automate GitHub Projects with ease"
inputs:
project:
description: Project board number
Expand Down Expand Up @@ -32,25 +32,31 @@ runs:

- name: Fetch project data
run: |
set -x
gh api graphql -f query='
query($org: String!, $num: Int!) {
organization(login: $org){
projectNext(number: $num) {
query ($org: String!, $num: Int!) {
organization(login: $org) {
projectV2(number: $num) {
id
fields(first: 20) {
nodes {
id
name
settings
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}' -f org=$ORG -F num=${{ inputs.project }} > project_data.json
echo 'PROJECT_ID='$(jq -r '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name == "Status").id' project_data.json) >> $GITHUB_ENV
echo 'TODO_OPTION_ID='$(jq -r '.data.organization.projectNext.fields.nodes[] | select(.name == "Status").settings | fromjson.options[] | select(.name=="${{ inputs.todo_status }}").id' project_data.json) >> $GITHUB_ENV
echo 'PROJECT_ID='$(jq -r '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name == "Status").id' project_data.json) >> $GITHUB_ENV
echo 'TODO_OPTION_ID='$(jq -r '.data.organization.projectV2.fields.nodes[] | select(.name == "Status").options[] | select(.name=="${{ inputs.todo_status }}").id' project_data.json) >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ inputs.token }}
ORG: ${{ inputs.org }}
Expand All @@ -69,15 +75,15 @@ runs:
run: |
item_id="$( gh api graphql -f query='
mutation($project: ID!, $id: ID!) {
addProjectNextItem(input: {
addProjectV2ItemById(input: {
projectId: $project,
contentId: $id,
}) {
projectNextItem {
item {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_PR_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
}' -f project=$PROJECT_ID -f id=$ISSUE_PR_ID --jq '.data.addProjectV2ItemById.item.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
env:
Expand All @@ -87,22 +93,14 @@ runs:
- name: Set fields on project ticket
run: |
gh api graphql -f query='
mutation (
$project: ID!
$item: ID!
$status_field: ID!
$status_value: String!
) {
updateProjectNextItemField(input: {
projectId: $project
itemId: $item
fieldId: $status_field
value: $status_value
}) {
projectNextItem {
id
}
}
mutation ($project: ID!, $item: ID!, $status_field: ID!, $status_value: String!) {
updateProjectV2ItemFieldValue(
input: {projectId: $project, itemId: $item, fieldId: $status_field, value: {singleSelectOptionId: $status_value}}
) {
projectV2Item {
id
}
}
}' -f project=$PROJECT_ID -f item=$ITEM_ID -f status_field=$STATUS_FIELD_ID -f status_value=$TODO_OPTION_ID
env:
GITHUB_TOKEN: ${{ inputs.token }}
Expand Down

0 comments on commit 40f5f75

Please sign in to comment.