From 2f9e3dc8c246a2132a74e10a22dfcfd7109e7587 Mon Sep 17 00:00:00 2001 From: Sarah Edwards Date: Wed, 21 Apr 2021 10:00:21 -0700 Subject: [PATCH 1/2] add workflow to transfer REST API schema fix requests from os docs repo to os OpenAPI repo (#18868) --- .../transfer-api-issue-to-openapi.yml | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/transfer-api-issue-to-openapi.yml diff --git a/.github/workflows/transfer-api-issue-to-openapi.yml b/.github/workflows/transfer-api-issue-to-openapi.yml new file mode 100644 index 000000000000..fac0bf96bb30 --- /dev/null +++ b/.github/workflows/transfer-api-issue-to-openapi.yml @@ -0,0 +1,55 @@ +name: Transfer REST API issue to rest-api-description + +# **What it does**: Transfers an issue in the open source repo to the open source rest-api-description repo +# **Why we have it**: Requests to change the OpenAPI schema (unless the schema is just a description update) should be made in github/rest-api-description +# **Who does it impact**: Open source and docs-content maintainers + +on: + issues: + types: + - labeled + +jobs: + transfer-issue: + name: Transfer issue + runs-on: ubuntu-latest + if: github.event.label.name == 'rest-schema' && github.repository == 'github/docs' + steps: + - name: Check if this run was triggered by a member of the docs team + uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9 + id: triggered-by-member + with: + github-token: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + result-encoding: string + script: | + const triggerer_login = context.payload.sender.login + const teamMembers = await github.request( + `/orgs/github/teams/docs/members?per_page=100` + ) + const logins = teamMembers.data.map(member => member.login) + if (logins.includes(triggerer_login)) { + console.log(`This workflow was triggered by ${triggerer_login} (on the docs team).`) + return 'true' + } + console.log(`This workflow was triggered by ${triggerer_login} (not on the docs team), so no action will be taken.`) + return 'false' + + - name: Exit if not triggered by a docs team member + if: steps.triggered-by-member.outputs.result == 'false' + run: | + echo Aborting. This workflow must be triggered by a member of the docs team. + exit 1 + + - name: Comment on the old issue + run: gh issue comment $OLD_ISSUE --body "Thank you for opening this issue! Changes to the REST API schema can be requested in [github/rest-api-description](https://github.com/github/rest-api-description). I will transfer your issue over to that open source repo." + env: + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + OLD_ISSUE: ${{ github.event.issue.html_url }} + + - name: Transfer the issue to the rest-api-description repo + run: | + new_issue_url="$(gh issue transfer $OLD_ISSUE github/rest-api-description)" + echo 'NEW_ISSUE='$new_issue_url >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + OLD_ISSUE: ${{ github.event.issue.html_url }} From c8dd174c2522e8ef51f919323079b783e37cac3b Mon Sep 17 00:00:00 2001 From: Sarah Edwards Date: Wed, 21 Apr 2021 10:13:24 -0700 Subject: [PATCH 2/2] Add workflow to copy REST description fix requests to docs-content (#18866) --- .../workflows/copy-api-issue-to-internal.yml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/copy-api-issue-to-internal.yml diff --git a/.github/workflows/copy-api-issue-to-internal.yml b/.github/workflows/copy-api-issue-to-internal.yml new file mode 100644 index 000000000000..db8d822cb5ad --- /dev/null +++ b/.github/workflows/copy-api-issue-to-internal.yml @@ -0,0 +1,69 @@ +name: Copy to REST API issue to docs-content + +# **What it does**: Copies an issue in the open source repo to the docs-content repo, comments on and closes the original issue +# **Why we have it**: REST API updates cannot be made in the open source repo. Instead, we copy the issue to an internal issue (we do not transfer so that the issue does not disappear for the contributor) and close the original issue. +# **Who does it impact**: Open source and docs-content maintainers + +on: + issues: + types: + - labeled + +jobs: + transfer-issue: + name: Transfer issue + runs-on: ubuntu-latest + if: github.event.label.name == 'rest-description' && github.repository == 'github/docs' + steps: + - name: Check if this run was triggered by a member of the docs team + uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9 + id: triggered-by-member + with: + github-token: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + result-encoding: string + script: | + const triggerer_login = context.payload.sender.login + const teamMembers = await github.request( + `/orgs/github/teams/docs/members?per_page=100` + ) + const logins = teamMembers.data.map(member => member.login) + if (logins.includes(triggerer_login)) { + console.log(`This workflow was triggered by ${triggerer_login} (on the docs team).`) + return 'true' + } + console.log(`This workflow was triggered by ${triggerer_login} (not on the docs team), so no action will be taken.`) + return 'false' + + - name: Exit if not triggered by a docs team member + if: steps.triggered-by-member.outputs.result == 'false' + run: | + echo Aborting. This workflow must be triggered by a member of the docs team. + exit 1 + + - name: Create an issue in the docs-content repo + run: | + new_issue_url="$(gh issue create --title "$ISSUE_TITLE" --body "$ISSUE_BODY" --repo github/docs-content)" + echo 'NEW_ISSUE='$new_issue_url >> $GITHUB_ENV + env: + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + ISSUE_TITLE: ${{ github.event.issue.title }} + ISSUE_BODY: ${{ github.event.issue.body }} + + - name: Comment on the new issue + run: gh issue comment $NEW_ISSUE --body "This issue was originally opened in the open source repo as $OLD_ISSUE" + env: + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + NEW_ISSUE: ${{ env.NEW_ISSUE }} + OLD_ISSUE: ${{ github.event.issue.html_url }} + + - name: Comment on the old issue + run: gh issue comment $OLD_ISSUE --body "Thank you for opening this issue! Updates to the REST API description must be made internally. I have copied your issue to an internal issue, so I will close this issue." + env: + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + OLD_ISSUE: ${{ github.event.issue.html_url }} + + - name: Close the old issue + run: gh issue close $OLD_ISSUE + env: + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} + OLD_ISSUE: ${{ github.event.issue.html_url }}