Skip to content

Transfer issues

Transfer issues #154

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
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