From 740caa49dcedca666b8b4a3b857b5b65184ed070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20La=C3=ADns?= Date: Sun, 26 May 2024 23:45:52 +0100 Subject: [PATCH] ci: fix update-project workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Successfull example: https://github.com/FFY00/test-label-mapping/issues/4 Signed-off-by: Filipe LaΓ­ns --- .github/workflows/update-project.yml | 49 ++++++++++++++++++++++------ query-project-by-number.gql | 36 ++++++++++++++++++++ update-project.json | 10 +++--- 3 files changed, 80 insertions(+), 15 deletions(-) create mode 100644 query-project-by-number.gql diff --git a/.github/workflows/update-project.yml b/.github/workflows/update-project.yml index 4337cce..7bf3a82 100644 --- a/.github/workflows/update-project.yml +++ b/.github/workflows/update-project.yml @@ -12,16 +12,45 @@ jobs: repository-projects: write steps: - uses: actions/checkout@v4 - - name: Get column name - id: get-column-name + - name: Get column ID + id: get-column run: | - value=$(jq -r .labelToColumn.\"${{ github.event.label.name }}\" update-project.json) - echo "name=$value" >>$GITHUB_OUTPUT - echo "Column Name: $value" + value=$(jq -r .labelToColumnId.\"${{ github.event.label.name }}\" update-project.json) + echo "id=$value" >>$GITHUB_OUTPUT + echo "Label: ${{ github.event.label.name }}" + echo "Column id: $value" + - name: Add issue to project + if: ${{ steps.get-column.outputs.id != 'null' }} + id: add-to-project + uses: actions/add-to-project@v1.0.1 + with: + project-url: https://github.com/orgs/pyOpenSci/projects/7 + github-token: ${{ secrets.GHPROJECT_TOKEN }} - name: Move issue to column - if: ${{ steps.get-column-name.outputs.name != 'null' }} - uses: alex-page/github-project-automation-plus@v0.9.0 + if: ${{ steps.get-column.outputs.id != 'null' }} + uses: octokit/graphql-action@v2.x with: - project: peer-review-status - column: ${{ steps.get-column-name.outputs.name }} - repo-token: ${{ secrets.GHPROJECT_TOKEN }} + query: | + mutation($project: ID!, $item: ID!, $field: ID!, $column: String!) { + updateProjectV2ItemFieldValue( + input: { + projectId: $project + itemId: $item + fieldId: $field + value: { + singleSelectOptionId: $column + } + } + ) { + projectV2Item { + id + } + } + } + variables: | + project: "PVT_kwDOAbmP7s4ASqjL" + item: ${{ steps.add-to-project.outputs.itemId }} + field: "PVTSSF_lADOAbmP7s4ASqjLzgL66FI" + column: ${{ steps.get-column.outputs.id }} + env: + GITHUB_TOKEN: ${{ secrets.GHPROJECT_TOKEN }} diff --git a/query-project-by-number.gql b/query-project-by-number.gql new file mode 100644 index 0000000..86aa713 --- /dev/null +++ b/query-project-by-number.gql @@ -0,0 +1,36 @@ +query($org: String!, $number: Int!) { + organization(login: $org) { + projectV2(number: $number) { + id + number + title + fields(first: 100) { + nodes { + __typename + ... on ProjectV2Field { + id + name + } + ... on ProjectV2IterationField { + id + name + configuration { + iterations { + startDate + id + } + } + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } +} diff --git a/update-project.json b/update-project.json index f7e3220..56fe742 100644 --- a/update-project.json +++ b/update-project.json @@ -1,8 +1,8 @@ { - "labelToColumn": { - "0/pre-review-checks": "pre-review-checks", - "1-editor-assigned": "under-review", - "6/pyOS-approved πŸš€πŸš€πŸš€": "pyos-accepted", - "9/joss-approved": "joss-accepted" + "labelToColumnId": { + "0/pre-review-checks": "f75ad846", + "1-editor-assigned": "fa21bd65", + "6/pyOS-approved πŸš€πŸš€πŸš€": "4c9dbbd2", + "9/joss-approved": "ed99bc7a" } }