-
Notifications
You must be signed in to change notification settings - Fork 41
80 lines (73 loc) · 2.88 KB
/
transfer-issues.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Transfer issues
# To run this action. You need to do the following:
#
# 1. Create a personal access token (Classic) with the `repo` and `read:org` scopes.
#
# URL: https://github.com/settings/tokens/new?description=transfer-issues-token&scopes=repo,read:org
#
# 2. Authorize the token for use with [SAML](https://github.com/latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on) on the `mozilla` org.
#
# 3. Create a secret in the repository with whatever name you want, and paste the token as the value.
#
# ex: $ gh secret set <secret-name> --body "<token_value>
#
# 4. Run the action with the secret name as the `secret_name` input.
#
# ex: `gh secret set <secret-name> --body "<token_value>" && gh workflow run 90730614 --field count="10" --field from_name="addons-server" --field secret_name="<secret-name>"`
#
# Note: you need to paste the PAT in body, so make sure to keep track of the value before saving it.
# Also verify the workflow ID is correct. You can run without arguments and select interactively.
#
# Note: After each run this action purges the secret from the repo action secrets.
# This prevents pollution or conflict. So you have to reset it every time.
on:
workflow_dispatch:
inputs:
count:
description: How many issues to transfer
default: "1"
required: true
issue_number:
description: "the issue number to transfer. Overrides count if set."
required: false
from_name:
description: "the name of the mozilla/<from_name repository to transfer issues from"
required: true
secret_name:
description: "the name of the secret containing the PAT for the repository to transfer issues to"
required: true
states:
description: "which states to include 1) [OPEN] 2) [OPEN, CLOSED]"
required: true
default: "[OPEN]"
permissions: write-all
concurrency:
group: transfer-${{ inputs.from_name}}
cancel-in-progress: false
jobs:
fetch_issues:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Transfer issues
env:
# Required inputs
GH_TOKEN: ${{ secrets[format('{0}', inputs.secret_name)] }}
FROM_NAME: ${{ inputs.from_name }}
# One or the other is required
COUNT: ${{ inputs.count }}
ISSUE_NUMBER: ${{ inputs.issue_number }}
# Optional input
STATES: ${{ inputs.states }}
shell: bash
run: ./scripts/transfer-issues.sh
- name: Delete secret
if: always()
shell: bash
env:
GH_TOKEN: ${{ secrets[format('{0}', inputs.secret_name)] }}
run: |
set -x
if gh secret list --json name --jq '.[] | .name' | grep -q "${{ inputs.secret_name }}"; then
gh secret delete ${{ inputs.secret_name }}
fi