From a238d2952d1ec296a68bd201d7b9f030f2d68fa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Mon, 29 Mar 2021 15:27:16 +0200 Subject: [PATCH] Dynamically resolve the column ID for "Needs review" --- .github/workflows/prauto.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/prauto.yml b/.github/workflows/prauto.yml index 2d642d721..9b6d1478d 100644 --- a/.github/workflows/prauto.yml +++ b/.github/workflows/prauto.yml @@ -10,7 +10,6 @@ jobs: env: GH_REPO: ${{ github.repository }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NEEDSREVIEWCOL: "MDEzOlByb2plY3RDb2x1bW43MTEwMTI4" PRID: ${{ github.event.pull_request.node_id }} PRBODY: ${{ github.event.pull_request.body }} PRNUM: ${{ github.event.pull_request.number }} @@ -26,10 +25,21 @@ jobs: gh pr close $PRNUM } + colID () { + gh api graphql -f query='query($owner:String!, $repo:String!) { + repository(owner:$owner, name:$repo) { + project(number:1) { + columns(first:10) { nodes {id,name} } + } + } + }' -F owner=:owner -F repo=:repo \ + -q ".data.repository.project.columns.nodes[] | select(.name | startswith(\"$1\")) | .id" + } + addToBoard () { gh api graphql --silent -f query=' mutation($colID:ID!, $pr:ID!) { addProjectCard(input: { projectColumnId: $colID, contentId: $prID }) { clientMutationId } } - ' -f colID="$NEEDSREVIEWCOL" -f prID="$PRID" + ' -f colID="$(colID "Needs review")" -f prID="$PRID" } if gh api orgs/cli/public_members/$PRAUTHOR --silent 2>/dev/null