Skip to content

Commit

Permalink
use PAT
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Mar 22, 2024
1 parent ad02ede commit d7a7287
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions .github/workflows/transfer-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
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

permissions: write-all

Expand All @@ -25,30 +28,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: meta
if: github.event_name == 'workflow_dispatch'

- name: Transfer issues
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets[format('{0}', inputs.secret_name)] }}
shell: bash
run: |
set -x

echo "token: $GH_TOKEN"
gh auth status

exit 0

if [[ ! "${{ env.ALLOWED_REPOS }}" =~ (^|,)"${{ inputs.from_name }}"(,|$) ]]; then
echo "Invalid from_name "${{ inputs.from_name }}". Exiting..."
exit 1
fi

echo "from_repo=${{ github.server_url }}/${{ github.repository_owner }}/${{ inputs.from_name }}" >> $GITHUB_OUTPUT
echo "to_repo=${{ github.server_url }}/${{ github.repository }}" >> $GITHUB_OUTPUT
echo "repo_label=repository:${{ inputs.from_name }}" >> $GITHUB_OUTPUT

- name: Transfer
if: github.event_name == 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
set -x

gh auth status
from_repo="${{ github.server_url }}/${{ github.repository_owner }}/${{ inputs.from_name }}"
to_repo="${{ github.server_url }}/${{ github.repository }}"
repo_label="repository:${{ inputs.from_name }}"

gh label clone ${{ steps.meta.outputs.from_repo }} -R ${{ steps.meta.outputs.to_repo }} --force

Expand Down Expand Up @@ -80,3 +80,14 @@ jobs:
cat old-issues.txt

cat new-issues.txt

- name: Delete secret
if: always()
shell: bash
env:
GH_TOKEN: ${{ secrets[format('{0}', inputs.secret_name)] }}
run: |
if gh secret list --json name --jq '.[] | .name' | grep -q "$SECRET_NAME"; then
gh secret delete ${{ inputs.secret_name }}
fi

0 comments on commit d7a7287

Please sign in to comment.