Skip to content

Commit 17c2df4

Browse files
ramyaparimiheiskr
andauthored
Workflow to transfer localization issues to localization repo (#21857)
* workflow to transfer localization issues * Update .github/workflows/transfer-to-localization-repo.yml Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com> * Update transfer-to-localization-repo.yml Co-authored-by: Kevin Heis <heiskr@users.noreply.github.com>
1 parent d6d40a9 commit 17c2df4

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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+
permissions:
8+
contents: write
9+
10+
on:
11+
issues:
12+
types:
13+
- labeled
14+
15+
jobs:
16+
transfer-issue:
17+
name: Transfer issue
18+
runs-on: ubuntu-latest
19+
if: (github.event.label.name == 'localization ' && github.repository == 'github/docs')
20+
steps:
21+
- name: Check if this run was triggered by a member of the docs team
22+
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
23+
id: triggered-by-member
24+
with:
25+
github-token: ${{secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES}}
26+
result-encoding: string
27+
script: |
28+
const triggerer_login = context.payload.sender.login
29+
const teamMembers = await github.request(
30+
`/orgs/github/teams/docs/members?per_page=100`
31+
)
32+
const logins = teamMembers.data.map(member => member.login)
33+
if (logins.includes(triggerer_login)) {
34+
console.log(`This workflow was triggered by ${triggerer_login} (on the docs team).`)
35+
return 'true'
36+
}
37+
console.log(`This workflow was triggered by ${triggerer_login} (not on the docs team), so no action will be taken.`)
38+
return 'false'
39+
40+
- name: Exit if not triggered by a docs team member
41+
if: steps.triggered-by-member.outputs.result == 'false'
42+
run: |
43+
echo Aborting. This workflow must be triggered by a member of the docs team.
44+
exit 1
45+
46+
- name: Create an issue in the localization repo
47+
run: |
48+
new_issue_url="$(gh issue create --title "$ISSUE_TITLE" --body "$ISSUE_BODY" --repo github/localization)"
49+
echo 'NEW_ISSUE='$new_issue_url >> $GITHUB_ENV
50+
env:
51+
GITHUB_TOKEN: ${{secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES}}
52+
ISSUE_TITLE: ${{ github.event.issue.title }}
53+
ISSUE_BODY: ${{ github.event.issue.body }}
54+
55+
- name: Comment on the new issue
56+
run: gh issue comment $NEW_ISSUE --body "This issue was originally opened in the open source repo as $OLD_ISSUE"
57+
env:
58+
GITHUB_TOKEN: ${{secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES}}
59+
NEW_ISSUE: ${{ env.NEW_ISSUE }}
60+
OLD_ISSUE: ${{ github.event.issue.html_url }}
61+
62+
- name: Comment on the old issue
63+
run: gh issue comment $OLD_ISSUE --body "Thank you for opening this issue! Updates to translated content must be made internally. I have copied your issue to an internal issue, so I will close this issue."
64+
env:
65+
GITHUB_TOKEN: ${{secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES}}
66+
OLD_ISSUE: ${{ github.event.issue.html_url }}
67+
68+
- name: Close the old issue
69+
run: gh issue close $OLD_ISSUE
70+
env:
71+
GITHUB_TOKEN: ${{secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES}}
72+
OLD_ISSUE: ${{ github.event.issue.html_url }}

0 commit comments

Comments
 (0)