From b47301e72793cd2615c1bbaa8d67bcbf4a466a16 Mon Sep 17 00:00:00 2001 From: Josh Ford Date: Fri, 7 Jun 2024 13:08:03 -0700 Subject: [PATCH] port all issue transfer logic --- .github/workflows/transfer-issue.yml | 49 ++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/.github/workflows/transfer-issue.yml b/.github/workflows/transfer-issue.yml index 6e42704..396d524 100644 --- a/.github/workflows/transfer-issue.yml +++ b/.github/workflows/transfer-issue.yml @@ -1,10 +1,47 @@ -name: Use Shared Workflow +name: Transfer New Issue to Docs Project + on: issues: - types: [opened, reopened] + types: [opened, reopened] jobs: - call-shared-workflow: - uses: near-examples/.github/.github/workflows/issue_mirror.yml@main - with: - github-token: ${{ secrets.GH_TOKEN }} + transfer: + runs-on: ubuntu-latest + steps: + - name: Transfer Issue to NEAR DevX + uses: actions/github-script@v5 + with: + github-token: ${{secrets.GH_TOKEN}} + script: | + const issueTitle = context.payload.issue.title; + const issueBody = context.payload.issue.body; + const issueNumber = context.payload.issue.number; + const organizationName = 'near'; + const projectName = 'NEAR Docs'; + + // Fetch project ID and other necessary IDs + const query = ` + query { + organization(login: "${organizationName}") { + projectV2(number: 117) { + id + } + } + } + `; + + const projectIdResponse = await github.graphql(query); + const projectId = projectIdResponse.organization.projectV2.id; + + // Add issue to the project + const mutation = ` + mutation($projectId: ID!, $contentId: ID!) { + addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) { + item { + id + } + } + } + `; + + await github.graphql(mutation, { projectId: projectId, contentId: context.payload.issue.node_id });