This is a standalone Go tool to allow you to sync from GitHub to a GitHub Enterprise instance. GitHub Enterprise is referred to as GHES throughout this document.
- Current status: ready for production use
- Download from: releases page
- Build status:
It is designed to work when:
- The GitHub Enterprise instance is separate from the rest of the internet.
- The GitHub Enterprise instance is connected to the rest of the internet.
Thank you for your interest in this GitHub action, however, right now we are not taking contributions.
We continue to focus our resources on strategic areas that help our customers be successful while making developers' lives easier. While GitHub Actions remains a key part of this vision, we are allocating resources towards other areas of Actions and are not taking contributions to this repository at this time. The GitHub public roadmap is the best place to follow along for any updates on features we’re working on and what stage they’re in.
We are taking the following steps to better direct requests related to GitHub Actions, including:
-
We will be directing questions and support requests to our Community Discussions area
-
High Priority bugs can be reported through Community Discussions or you can report these to our support team https://support.github.com/contact/bug-report.
-
Security Issues should be handled as per our security.md
We will still provide security updates for this project and fix major breaking changes during this time.
You are welcome to still raise bugs in this repo.
When there are machines which have access to both the public internet and the GHES instance run actions-sync sync.
Command:
actions-sync sync
Arguments:
cache-dir(required) The directory in which to cache repositories as they are synced. This speeds up re-syncing.destination-url(required) The URL of the GHES instance to sync repositories onto.destination-token(required) A personal access token to authenticate against the GHES instance when uploading repositories. See Destination token scopes below.source-token(optional) A token used to authenticate against the source when pulling private repositories. For a personal access token, thereposcope (read access to the source repositories) is sufficient. For a GitHub App installation token (ghs_*), the installation needs read access to the source repositories' contents; App tokens use installation permissions, not OAuth scopes. Must be used with anhttps://source-url.default-branch-only(optional) Only synchronize the single default branch rather than the default behaviour of syncing all branches. Tags are always synced. The default branch is always refreshed, including on subsequent runs into an existingcache-dir, but no other branches are pulled. If a repository was previously cached without this flag, the extra branches already in thecache-dirare left as-is (they are neither updated nor removed).repo-name(optional) A single repository to be synced. In the format ofowner/repo. Optionally if you wish the repository to be named different on your GHES instance you can provide an alias in the format:upstream_owner/upstream_repo:destination_owner/destination_reporepo-name-list(optional) A comma-separated list of repositories to be synced. Each entry follows the format ofrepo-name.repo-name-list-file(optional) A path to a file containing a newline separated list of repositories to be synced. Each entry follows the format ofrepo-name.actions-admin-user(optional) The name of the Actions admin user, which will be used for updating the chosen action. To use the default user, passactions-admin. If not set, the impersonation is disabled. Note thatsite_adminscope is required in the token for the impersonation to work.github-app-auth(optional) Authenticate using a GitHub App installation token (ghs_*) instead of a personal access token. App tokens have no user context, so the user API call is skipped and repositories are created under the owner taken from the destination repo name, which must be an organization the App is installed on (installation tokens cannot create user-owned repositories). See GitHub App authentication below.batch-size(optional) Number of refs to push in each batch. Default is 0 (no batching). Use a value like 100 if pushing fails for large repositories with many branches and tags.
Example Usage:
actions-sync sync \
--cache-dir "/tmp/cache" \
--destination-token "token" \
--destination-url "https://www.example.com" \
--repo-name actions/setup-node
When no machine has access to both the public internet and the GHES instance:
actions-sync pullon a machine with public internet access- copy the provided
cache-dirto a machine with access to the GHES instance - run
actions-sync pushon the machine with access to the GHES instance
Command:
actions-sync pull
Arguments:
cache-dir(required) The directory to cache the pulled repositories into.source-token(optional) A token used to authenticate against the source when pulling private repositories. For a personal access token, thereposcope (read access to the source repositories) is sufficient. For a GitHub App installation token (ghs_*), the installation needs read access to the source repositories' contents; App tokens use installation permissions, not OAuth scopes. Must be used with anhttps://source-url.default-branch-only(optional) Only synchronize the single default branch rather than the default behaviour of syncing all branches. Tags are always synced. The default branch is always refreshed, including on subsequent runs into an existingcache-dir, but no other branches are pulled. If a repository was previously cached without this flag, the extra branches already in thecache-dirare left as-is (they are neither updated nor removed).repo-name(optional) A single repository to be synced. In the format ofowner/repo. Optionally if you wish the repository to be named different on your GHES instance you can provide an alias in the format:upstream_owner/upstream_repo:destination_owner/destination_reporepo-name-list(optional) A comma-separated list of repositories to be synced. Each entry follows the format ofrepo-name.repo-name-list-file(optional) A path to a file containing a newline separated list of repositories to be synced. Each entry follows the format ofrepo-name.
Example Usage:
bin/actions-sync pull \
--cache-dir "/tmp/cache" \
--repo-name actions/setup-node
Command:
actions-sync push
Arguments:
cache-dir(required) The directory containing the repositories fetched using thepullcommand.destination-url(required) The URL of the GHES instance to sync repositories onto.destination-token(required) A personal access token to authenticate against the GHES instance when uploading repositories. See Destination token scopes below.repo-name,repo-name-listorrepo-name-list-file(optional) Limit push to specific repositories in the cache directory.actions-admin-user(optional) The name of the Actions admin user, which will be used for updating the chosen action. To use the default user, passactions-admin. If not set, the impersonation is disabled. Note thatsite_adminscope is required in the token for the impersonation to work.github-app-auth(optional) Authenticate using a GitHub App installation token (ghs_*) instead of a personal access token. App tokens have no user context, so the user API call is skipped and repositories are created under the owner taken from the destination repo name, which must be an organization the App is installed on (installation tokens cannot create user-owned repositories). See GitHub App authentication below.batch-size(optional) Number of refs to push in each batch. Default is 0 (no batching). Use a value like 100 if pushing fails for large repositories with many branches and tags.
Example Usage:
bin/actions-sync push \
--cache-dir "/tmp/cache" \
--destination-token "token" \
--destination-url "https://www.example.com"
When creating a personal access token include the repo and workflow scopes. Include the site_admin scope (optional) if you want organizations to be created as necessary or you want to use the impersonation logic for the push or sync commands.
Instead of a personal access token you can authenticate push/sync using a GitHub App installation token (ghs_*). This avoids long-lived PATs and aligns with enterprise security practices.
- Create a GitHub App on the destination GHES instance and install it on the target organization(s). The destination owner must be an organization: installation tokens cannot create user-owned repositories (
POST /user/reposrequires user context that App tokens lack), so a user-account installation will not work. - Grant the App these repository permissions:
Administration: Read & write(to create repositories),Contents: Read & writeandMetadata: Read-only. AddWorkflows: Read & writeif the synced repositories contain workflow files. - Generate an installation access token (
ghs_*) for the installation. - Pass the token as
--destination-tokentogether with the--github-app-authflag:
actions-sync push \
--cache-dir "/tmp/cache" \
--destination-token "ghs_xxxxxxxxxxxxxxxxxxxx" \
--destination-url "https://www.example.com" \
--github-app-auth
Notes:
- App installation tokens have no user context, so
--github-app-authskips theGET /usercall and creates repositories under the owner taken from the destination repo name (owner/repo) viaPOST /orgs/{owner}/repos. The owner must therefore be an organization the App is installed on; user-owned destinations are not supported because installation tokens cannot create user-owned repositories. - Organization auto-creation and user-impersonation (
--actions-admin-user) rely on user/site-admin context and are not used with App auth.
