From 1937a73d46845e8de54024067f544531f2af30a1 Mon Sep 17 00:00:00 2001 From: Chris Pine Date: Thu, 25 Jan 2024 12:35:36 -0800 Subject: [PATCH] Use shared workflow Changes this workflow to use a shared workflow, which will make it easier to manage across all repos in this org. --- .github/workflows/add-to-project.yaml | 76 ++------------------------- 1 file changed, 4 insertions(+), 72 deletions(-) diff --git a/.github/workflows/add-to-project.yaml b/.github/workflows/add-to-project.yaml index af6f4ba..7dc0caf 100644 --- a/.github/workflows/add-to-project.yaml +++ b/.github/workflows/add-to-project.yaml @@ -15,75 +15,7 @@ on: - created jobs: - add-to-project: - name: Add issue to project - runs-on: ubuntu-latest - steps: - - name: Get GitHub app token - uses: actions/create-github-app-token@v1 - id: app_token - with: - app-id: ${{ secrets.CONNECT_EXPORT_APP_ID }} - private-key: ${{ secrets.CONNECT_EXPORT_APP_KEY }} - - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/connectrpc/projects/1 - github-token: ${{ steps.app_token.outputs.token }} - - name: Get project id if status is done - if: ${{ github.event_name == 'issue_comment' }} - id: get_project_item_id - env: - GH_TOKEN: ${{ steps.app_token.outputs.token }} - run: | - 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 }}) @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 - fieldValueByName(name: "Status") { - ... on ProjectV2ItemFieldSingleSelectValue { - optionId - } - } - project { - number - } - } - } - } - } - }' | 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: - GH_TOKEN: ${{ steps.app_token.outputs.token }} - run: | - gh api graphql -f query='mutation { - updateProjectV2ItemFieldValue( - input: { - fieldId: "PVTSSF_lADOBcwMos4AX_p_zgPVtzo" - itemId: "${{ steps.get_project_item_id.outputs.item_id }}" - projectId: "PVT_kwDOBcwMos4AX_p_" - value: { singleSelectOptionId: "80a785d9" } - } - ) { - clientMutationId - } - }' + call-workflow-add-to-project: + name: Call workflow to add issue to project + uses: connectrpc/base-workflows/.github/workflows/add-to-projects.yaml@main + secrets: inherit