Skip to content

Commit 49e5d20

Browse files
authored
Branch was updated using the 'autoupdate branch' Actions workflow.
2 parents 74e1d66 + c8dd174 commit 49e5d20

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Copy to REST API issue to docs-content
2+
3+
# **What it does**: Copies an issue in the open source repo to the docs-content repo, comments on and closes the original issue
4+
# **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.
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-description' && 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: Create an issue in the docs-content repo
44+
run: |
45+
new_issue_url="$(gh issue create --title "$ISSUE_TITLE" --body "$ISSUE_BODY" --repo github/docs-content)"
46+
echo 'NEW_ISSUE='$new_issue_url >> $GITHUB_ENV
47+
env:
48+
GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}}
49+
ISSUE_TITLE: ${{ github.event.issue.title }}
50+
ISSUE_BODY: ${{ github.event.issue.body }}
51+
52+
- name: Comment on the new issue
53+
run: gh issue comment $NEW_ISSUE --body "This issue was originally opened in the open source repo as $OLD_ISSUE"
54+
env:
55+
GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}}
56+
NEW_ISSUE: ${{ env.NEW_ISSUE }}
57+
OLD_ISSUE: ${{ github.event.issue.html_url }}
58+
59+
- name: Comment on the old issue
60+
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."
61+
env:
62+
GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}}
63+
OLD_ISSUE: ${{ github.event.issue.html_url }}
64+
65+
- name: Close the old issue
66+
run: gh issue close $OLD_ISSUE
67+
env:
68+
GITHUB_TOKEN: ${{secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES}}
69+
OLD_ISSUE: ${{ github.event.issue.html_url }}

0 commit comments

Comments
 (0)