|
| 1 | +name: Transfer REST API issue to rest-api-description |
| 2 | + |
| 3 | +# **What it does**: Transfers an issue in the open source repo to the open source rest-api-description repo |
| 4 | +# **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 |
| 5 | +# **Who does it impact**: Open source and docs-content maintainers |
| 6 | + |
| 7 | +on: |
| 8 | + issues: |
| 9 | + types: |
| 10 | + - labeled |
| 11 | + |
| 12 | +jobs: |
| 13 | + transfer-issue: |
| 14 | + name: Transfer issue |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: github.event.label.name == 'rest-schema' && github.repository == 'github/docs' |
| 17 | + steps: |
| 18 | + - name: Check if this run was triggered by a member of the docs team |
| 19 | + uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9 |
| 20 | + id: triggered-by-member |
| 21 | + with: |
| 22 | + github-token: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} |
| 23 | + result-encoding: string |
| 24 | + script: | |
| 25 | + const triggerer_login = context.payload.sender.login |
| 26 | + const teamMembers = await github.request( |
| 27 | + `/orgs/github/teams/docs/members?per_page=100` |
| 28 | + ) |
| 29 | + const logins = teamMembers.data.map(member => member.login) |
| 30 | + if (logins.includes(triggerer_login)) { |
| 31 | + console.log(`This workflow was triggered by ${triggerer_login} (on the docs team).`) |
| 32 | + return 'true' |
| 33 | + } |
| 34 | + console.log(`This workflow was triggered by ${triggerer_login} (not on the docs team), so no action will be taken.`) |
| 35 | + return 'false' |
| 36 | +
|
| 37 | + - name: Exit if not triggered by a docs team member |
| 38 | + if: steps.triggered-by-member.outputs.result == 'false' |
| 39 | + run: | |
| 40 | + echo Aborting. This workflow must be triggered by a member of the docs team. |
| 41 | + exit 1 |
| 42 | +
|
| 43 | + - name: Comment on the old issue |
| 44 | + 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." |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} |
| 47 | + OLD_ISSUE: ${{ github.event.issue.html_url }} |
| 48 | + |
| 49 | + - name: Transfer the issue to the rest-api-description repo |
| 50 | + run: | |
| 51 | + new_issue_url="$(gh issue transfer $OLD_ISSUE github/rest-api-description)" |
| 52 | + echo 'NEW_ISSUE='$new_issue_url >> $GITHUB_ENV |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}} |
| 55 | + OLD_ISSUE: ${{ github.event.issue.html_url }} |
0 commit comments