From 9aefecb6ca9e7f7b6281311c81e466af45c00fb0 Mon Sep 17 00:00:00 2001 From: Sarah Edwards Date: Thu, 30 Nov 2023 12:12:04 -0800 Subject: [PATCH] Add workflow to add docs-internal PRs to the v2 docs-content fr board (#46995) --- .../first-responder-docs-content-v2.yml | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/first-responder-docs-content-v2.yml diff --git a/.github/workflows/first-responder-docs-content-v2.yml b/.github/workflows/first-responder-docs-content-v2.yml new file mode 100644 index 0000000000..f1eac0e1eb --- /dev/null +++ b/.github/workflows/first-responder-docs-content-v2.yml @@ -0,0 +1,90 @@ +name: WIP TRIAL REPLACEMENT of First responder docs-content + +# **What it does**: New pull requests automatically add to the content first responder board. +# **Why we have it**: So we don't lose track of new pull reuqests for docs-content to review. +# **Who does it impact**: Docs content. + +# todo removed the unlabeled trigger and the step where removing the docs-content-fr label removes the PR from the FR board. Do we want to change the status to Done when the label is removed? If so, add back the unlabeled trigger and write a step to do this + +# todo removed the closed trigger and the step where closing the PR removes the PR from the FR board (this will be taken care of by the built in automation that changes the status to Done when items are closed) + +on: + pull_request: + types: + - reopened + - opened + - ready_for_review + +permissions: + contents: read + +jobs: + first-responder-triage-pr: + name: Triage PR to FR project board + if: github.repository == 'github/docs-internal' && github.event.pull_request.draft == false && github.actor != 'dependabot[bot]' && github.event.pull_request.head.ref != 'repo-sync' + runs-on: ubuntu-latest + + steps: + # TODO this (otherwise unchanged) step is temporarily commented out so that we can test that the subsequent steps are working + # - name: Check if the event originated from a team member + # uses: actions/github-script@e69ef5462fd455e02edcaf4dd7708eda96b9eda0 + # id: set-result + # with: + # github-token: ${{secrets.DOCS_BOT_PAT_WORKFLOW_READORG}} + # result-encoding: string + # script: | + # const repoName = context.payload.repository.name + # const ownerName = context.payload.repository.owner.login + # const issueNumber = (context.eventName === "issues") ? context.payload.issue.number : context.payload.number + # const updatedIssueInformation = await github.rest.issues.get({ + # owner: ownerName, + # repo: repoName, + # issue_number: issueNumber + # }) + # const teamMembers = await github.request( + # `/orgs/github/teams/docs/members?per_page=100` + # ) + # const teamLogins = teamMembers.data.map(member => member.login) + # if (teamLogins.some(login => login === updatedIssueInformation.data.user.login)) { + # console.log(`This issue or pull request was authored by a member of the github/docs team.`) + # return 'true' + # } + # console.log(`This issue or pull request was authored by an external contributor.`) + # return 'false' + + # TODO this (otherwise unchanged) step is commented out so that we don't add our test PRs to the FR board by virtue of adding the fr label + # - name: Label external contributor pull requests with docs-content-fr + # uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 + # if: ${{ steps.set-result.outputs.result == 'false' }} + # with: + # repo-token: '${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }}' + # add-labels: 'docs-content-fr' + + # Add to the FR project + # and set type to "External contributor PR" + # and set date to now + - name: Triage to FR PR project + if: steps.set-result.outputs.result == 'false' + env: + GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_WORKFLOW_READORG }} + PR_URL: ${{ github.event.pull_request.html_url }} + PROJECT_NUMBER: 11672 + PROJECT_ID: PVT_kwDNJr_OAGNkBg + TYPE_FIELD_ID: PVTSSF_lADNJr_OAGNkBs4D-Nyn + EXTERNAL_PR_TYPE_ID: bbd0922a + run: | + echo "Adding item to project..." + + ITEM_ID=$(gh project item-add $PROJECT_NUMBER --owner github --url $PR_URL --format json | jq .id) + + echo "Editing type..." + + gh project item-edit --project-id $PROJECT_ID --id $ITEM_ID --field-id $TYPE_FIELD_ID --single-select-option-id $EXTERNAL_PR_TYPE_ID + + echo "Editing date..." + + DATE=$(date '+%Y-%m-%d') + + gh project item-edit --project-id $PROJECT_ID --id $ITEM_ID --field-id $TYPE_FIELD_ID --date $DATE + + echo "done editing"