🤝
Resources - External (Unlisted)
  • Mirroring
    • Azure DevOps
    • GitHub
    • GitLab
Powered by GitBook
On this page
  1. Mirroring

GitHub

This page describes the process to mirror a Copia repo to a GitHub repo.

PreviousAzure DevOpsNextGitLab

Last updated 8 months ago

Copia is providing these instructions to help customers. We do not officially support this feature and cannot guarantee the accuracy of these instructions.

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 .

See for a walkthrough tutorial for mirroring a Copia repo to GitHub.

  1. Navigate to the Copia repo you want to mirror. Then navigate to the default branch at the top level.

  2. Within your chosen repo, create a folder called .github

  3. Within the .github folder, create another folder called workflows

  4. Within this folder, create a file called mirror-workflow.yml, or something comparable

  5. Copy and paste the code seen below

    1. Modify the source_repo field with the URL of the Copia repo that you'd like to mirror

    2. Modify the "on:" field to trigger this action on 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 .

  6. Commit and push your code to the main branch of the Copia repo

  7. Now it's time to move to GitHub. Once in GitHub, follow the directions to

  8. 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)

    1. MIRROR_SOURCE_TOKEN_COPIA: Token created on the Copia website at

    2. MIRROR_SOURCE_USER_COPIA: Copia username of the user who is associated with the token

    3. MIRROR_TARGET_TOKEN_GITHUB: for the user associated with the GitHub account

    4. MIRROR_TARGET_USER_GITHUB: GitHub username of the user who is associated with the PAT

  9. By default, imported repositories in GitHub have Actions disabled. Go to the repository settings and select the "Allow all actions and reusable workflows"

  10. 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 }}"
here
this video
any event
here
import repository
https://app.copia.io/user/settings/applications
Personal Access Token (PAT)
Page cover image