-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token to create orgA/repo from orgB template #96
Comments
Unless the template repository is open source, I don't think this is possible with a GitHub App installation access token, because by design an installation access token only has access to the account that the installation belongs to. There are no cross-account installations |
Thanks for the clarification @gr2m 👌🏼, my workaround for this was to git checkout the repo using the GitHub Workflow token, clean the git repo history, and then use the GitHub App access token to create the new repo. - name: Generate a token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.BOT_APP_ID }}
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
owner: ${{ github.event.inputs.repo-org }}
- name: Checkout template repo
id: checkout
uses: actions/checkout@v4
- name: Initialize the new repo
id: init-repo
run: |
## clean git
rm -rf .git
## set git config
git config --global init.defaultBranch main
## commit initial files
git init
git config user.name "${{ vars.BOT_APP_NAME }}[bot]"
git config user.email "${{ secrets.BOT_APP_ID }}+${{ vars.BOT_APP_NAME }}[bot]@users.noreply.github.com"
git add .
git commit -m "initial commit [skip ci]"
- name: Create the new repo
id: create-repo
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh repo create ${{ github.event.inputs.repo-org }}/${{ github.event.inputs.repo-name }} \
--internal \
--source=. \
--remote=upstream \
--push
##--template ${{ github.repository }} |
I have been trying to enable a Github Workflow that should be able to create a new repo at orgA, using a template repo from orgB, I don't believe there is a chance to support this since the GitHub Apps tokens are scoped to an individual account or a specific org afaik, but it could be pretty useful to have a way to support this using GitHub Apps.
These are the steps, I'm trying to use:
This is similar to Issue 45, but I can't use the matrix approach since permission to both orgs is required between the same command exec.
The text was updated successfully, but these errors were encountered: