GitHub
This page describes the process to mirror a Copia repo to a GitHub repo.
NOTE: GitHub does not natively support Pull-based Mirroring. As a result of this, users must manually set up GitHub Actions to trigger, which then execute code to mirror the repo to GitHub. This is a clunky process because it requires that the GitHub action file gets added to both the GitHub repo the very first time, as well as the Copia repo, since the contents of the GitHub repo will be overwritten.
Another challenge is that scheduled Cron jobs in GitHub actions do not tend to trigger on time, so it is not a very deterministic way of backing up files from Copia. In order to do this in a more deterministic manner, users would need to use an external scheduler to tell the GitHub API to start the workflow. See more info on this here.
See this video for a walkthrough tutorial for mirroring a Copia repo to GitHub.
Navigate to the Copia repo you want to mirror. Then navigate to the default branch at the top level.
Within your chosen repo, create a folder called .github
Within the .github folder, create another folder called workflows
Within this folder, create a file called mirror-workflow.yml, or something comparable
Copy and paste the code seen below
Modify the
source_repo
field with the URL of the Copia repo that you'd like to mirrorModify the "on:" field to trigger this action on any event that you'd like. The example code is scheduled to run every 5 minutes. NOTE: GitHub only attempts to run the workflow on the schedule. It is likely that the action will actually be delayed due to constraints in the GitHub system. See more info on this here.
Commit and push your code to the main branch of the Copia repo
Now it's time to move to GitHub. Once in GitHub, follow the directions to import repository
In your repository, you must add the following secrets (NOTE: These could conceivably be organizational secrets instead, which would avoid you needing to add them to every repo that is created)
MIRROR_SOURCE_TOKEN_COPIA
: Token created on the Copia website at https://app.copia.io/user/settings/applicationsMIRROR_SOURCE_USER_COPIA
: Copia username of the user who is associated with the tokenMIRROR_TARGET_TOKEN_GITHUB
: Personal Access Token (PAT) for the user associated with the GitHub accountMIRROR_TARGET_USER_GITHUB
: GitHub username of the user who is associated with the PAT
By default, imported repositories in GitHub have Actions disabled. Go to the repository settings and select the "Allow all actions and reusable workflows"
The example code, shown below, has the ability to manually trigger the workflow. In your GitHub repository, if you click on "Actions" and then select "Mirror files action" and then select "Run workflow" you can trigger an immediate run of the workflow to ensure that the workflow was successful
name: 'Mirror files action'
on:
schedule:
- cron: '*/5 * * * *' # Requests to run every 5 minutes (GitHub will be unlikely to be able to actually run this quickly
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
Mirror:
runs-on: ubuntu-latest
steps:
- uses: pkgstore/github-action-mirror@main
with:
source_repo: "https://app.copia.io/[organization]/[repo]"
source_user: "${{ secrets.MIRROR_SOURCE_USER_COPIA }}"
source_token: "${{ secrets.MIRROR_SOURCE_TOKEN_COPIA }}"
target_repo: "https://github.com/${{ github.repository }}.git"
target_user: "${{ secrets.MIRROR_TARGET_USER_GITHUB }}"
target_token: "${{ secrets.MIRROR_TARGET_TOKEN_GITHUB }}"
Last updated