From 3b86fa4af3b7ed6ef227ba20a584ee1745664114 Mon Sep 17 00:00:00 2001 From: Sri Date: Thu, 25 Jan 2024 23:20:43 +0530 Subject: [PATCH] Handle PR case --- .github/workflows/add-to-project.yaml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/add-to-project.yaml b/.github/workflows/add-to-project.yaml index 2e349b6..af6f4ba 100644 --- a/.github/workflows/add-to-project.yaml +++ b/.github/workflows/add-to-project.yaml @@ -38,7 +38,22 @@ jobs: echo item_id=$(gh api graphql -f query='query { repository(name: "${{ github.event.repository.name }}", owner: "${{ github.event.repository.owner.login }}") { name - issue(number: ${{ github.event.issue.number }}) { + issue(number: ${{ github.event.issue.number }}) @include(if: ${{ github.event.issue.pull_request == null }}) { + projectItems(first: 100) { + nodes { + id + fieldValueByName(name: "Status") { + ... on ProjectV2ItemFieldSingleSelectValue { + optionId + } + } + project { + number + } + } + } + } + pullRequest(number: ${{ github.event.issue.number }}) @include(if: ${{ github.event.issue.pull_request != null }}) { projectItems(first: 100) { nodes { id @@ -54,7 +69,7 @@ jobs: } } } - }' | jq -r '.data.repository.issue.projectItems.nodes | .[] | select(.project.number==1 and .fieldValueByName.optionId == "dea0b2c9") | .id') >> $GITHUB_OUTPUT + }' | jq -r 'if .data.repository.issue != null then .data.repository.issue else .data.repository.pullRequest end | .projectItems.nodes | .[] | select(.project.number==1 and .fieldValueByName.optionId == "dea0b2c9") | .id') >> $GITHUB_OUTPUT - name: "Update status" if: ${{ steps.get_project_item_id.outputs.item_id != '' }} env: