1
0
mirror of synced 2025-12-30 03:01:36 -05:00
Files
docs/.github/workflows/transfer-api-issue-to-openapi.yml
dependabot[bot] 6ff1b03d59 Bump actions/github-script from 6.4.0 to 7.0.0 (#46199)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Robert Sese <734194+rsese@users.noreply.github.com>
2023-11-20 19:36:44 +00:00

68 lines
2.9 KiB
YAML

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
permissions:
contents: read
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@e69ef5462fd455e02edcaf4dd7708eda96b9eda0
id: triggered-by-member
with:
github-token: ${{secrets.DOCS_BOT_PAT_WORKFLOW_READORG}}
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.DOCS_BOT_PAT_WORKFLOW_READORG}}
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.DOCS_BOT_PAT_WORKFLOW_READORG}}
OLD_ISSUE: ${{ github.event.issue.html_url }}
- name: Check out repo
if: ${{ failure() }}
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: ./.github/actions/slack-alert
if: ${{ failure() }}
with:
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}