From 7916570abbfe58031dbd8ef3cfe79e23fb7488ec Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sun, 8 May 2022 13:04:24 +0200 Subject: [PATCH] workflows: add new PRs to review board Signed-off-by: Patrik Oldsberg --- .github/workflows/automate_review-labels.yaml | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automate_review-labels.yaml b/.github/workflows/automate_review-labels.yaml index 3393344ddf..cae71f6aaa 100644 --- a/.github/workflows/automate_review-labels.yaml +++ b/.github/workflows/automate_review-labels.yaml @@ -16,14 +16,14 @@ jobs: label: runs-on: ubuntu-latest steps: + # THESE SCRIPTS SHOULD BE INLINED AND NOT IN REPO + # DUE TO THE TOKEN PERMISSIONS THAT ARE GIVEN + # TO THE WORKFLOW. THIS SCRIPT WILL AND SHOULD + # RUN FROM THE BASE REPO ALL TIMES. - uses: actions/github-script@v6 id: fix-labels with: github-token: ${{ secrets.GITHUB_TOKEN }} - # THIS SCRIPT SHOULD BE INLINED AND NOT IN REPO - # DUE TO THE TOKEN PERMISSIONS THAT ARE GIVEN - # TO THE WORKFLOW. THIS SCRIPT WILL AND SHOULD - # RUN FROM THE BASE REPO ALL TIMES. script: | if (['opened', 'synchronize'].includes('${{ github.event.action }}')) { // if it's the author, always add awaiting-review label @@ -48,3 +48,37 @@ jobs: console.log(e) }); } + + - name: Add PRs to review board + uses: actions/github-script@v6 + if: github.event.action == 'opened' || github.event.action == 'reopened' + env: + PROJECT_ID: PN_kwDOBFKqdc02LQ + with: + github-token: ${{ secrets.GH_SERVICE_ACCOUNT_TOKEN }} + script: | + const prLookup = await github.graphql(` + query($owner: String!, $repo: String!, $number: Int!){ + repository(owner: $owner, name: $repo) { + pullRequest(number: $number) { + id + } + } + } + `, context.issue); + + await github.graphql(` + mutation($projectId: ID!, $contentId: ID!) { + addProjectNextItem(input: { + projectId: $projectId, + contentId: $contentId, + }) { + projectNextItem { + id + } + } + } + `, { + projectId: process.env.PROJECT_ID, + contentId: prLookup.repository.pullRequest.id + })