No description
  • Go 69.4%
  • Shell 27.2%
  • PowerShell 3.4%
Find a file
Philip Gai 8d10c36b44
feat: add --batch-size flag to push refs in batches (#173)
* feat: add --batch-size flag to push refs in batches

Add support for pushing refs in smaller batches to avoid server-side
limits and timeouts when syncing large repositories with many tags/branches.

- Add --batch-size flag (default 0 = no batching, original behavior)
- Add References() method to GitRepository interface
- Implement collectRefs() and pushRefsInBatches() helpers
- Add MinBatchSize validation (must be 0 or >= 10)

This addresses issues where repositories with 1000+ refs fail to sync
to GHES with 'command error on refs/heads/<branch>: failed' errors.

* test: add tests for batch-size flag and push batching functionality

* fix: pin tool dependencies to versions compatible with Go 1.21

* ci: fix docker compose v2 syntax and update setup-ruby action

* refactor: address PR review feedback

- Remove unused RefInfo struct from git.go
- Remove redundant pushedAny variable tracking in pushRefsInBatches
- Remove incomplete TestPushRefsInBatches_PartialUpToDate test (already covered by existing test case)

* docs: add --batch-size flag to README
2026-01-27 15:19:55 -06:00
.github feat: add --batch-size flag to push refs in batches (#173) 2026-01-27 15:19:55 -06:00
.licenses/src/go Auto-update license files 2024-04-19 13:27:39 +00:00
_tools upgrading version of golangci-lint to latest in script/bootstrap 2024-01-16 15:16:40 -06:00
cmd Honor repo flags on sync and push 2020-09-18 17:15:16 -04:00
docs adhere to comments and add spelling fixes 2022-11-28 05:01:50 +00:00
script feat: add --batch-size flag to push refs in batches (#173) 2026-01-27 15:19:55 -06:00
src feat: add --batch-size flag to push refs in batches (#173) 2026-01-27 15:19:55 -06:00
test updating github.go ot use io pkg instead of ioutil pkg after Go 1.21 upgrade 2024-01-16 15:33:03 -06:00
vendor Bump golang.org/x/net from 0.22.0 to 0.23.0 2024-04-19 13:26:21 +00:00
.dockerignore Rename project to actions-sync 2020-07-02 19:36:10 +01:00
.gitattributes Rename project to actions-sync 2020-07-02 19:36:10 +01:00
.gitignore Add the compiled binary to git ignore 2022-09-09 09:35:07 +00:00
.golangci.yaml update linters 2023-03-16 02:29:51 +00:00
.goreleaser.yml simplifying goreleaser config. explicitly set CGO_ENABLED=0 2024-04-23 11:05:23 -05:00
.licensed.yml updating licenses ci workflow. regenerating licenses cache 2024-01-17 14:34:50 -06:00
CODE_OF_CONDUCT.md Rename project to actions-sync 2020-07-02 19:36:10 +01:00
CONTRIBUTING.md Rename project to actions-sync 2020-07-02 19:36:10 +01:00
docker-compose.yml Rename project to actions-sync 2020-07-02 19:36:10 +01:00
Dockerfile.cibuild updating Go version to 1.21. Ran tidy and mod vendor 2024-01-16 14:23:08 -06:00
go.mod Bump golang.org/x/net from 0.22.0 to 0.23.0 2024-04-19 13:26:21 +00:00
go.sum Bump golang.org/x/net from 0.22.0 to 0.23.0 2024-04-19 13:26:21 +00:00
LICENSE Rename project to actions-sync 2020-07-02 19:36:10 +01:00
main.go Rename project to actions-sync 2020-07-02 19:36:10 +01:00
README.md feat: add --batch-size flag to push refs in batches (#173) 2026-01-27 15:19:55 -06:00

Actions Sync

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: Actions Sync 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.

Note

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 were working on and what stage theyre in.

We are taking the following steps to better direct requests related to GitHub Actions, including:

  1. We will be directing questions and support requests to our Community Discussions area

  2. 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.

  3. 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.

Connected instances

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.
  • repo-name (optional) A single repository to be synced. In the format of owner/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_repo
  • repo-name-list (optional) A comma-separated list of repositories to be synced. Each entry follows the format of repo-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 of repo-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, pass actions-admin. If not set, the impersonation is disabled. Note that site_admin scope is required in the token for the impersonation to work.
  • 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

Not connected instances

When no machine has access to both the public internet and the GHES instance:

  1. actions-sync pull on a machine with public internet access
  2. copy the provided cache-dir to a machine with access to the GHES instance
  3. run actions-sync push on the machine with access to the GHES instance

Command:

actions-sync pull

Arguments:

  • cache-dir (required) The directory to cache the pulled repositories into.
  • repo-name (optional) A single repository to be synced. In the format of owner/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_repo
  • repo-name-list (optional) A comma-separated list of repositories to be synced. Each entry follows the format of repo-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 of repo-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 the pull command.
  • 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-list or repo-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, pass actions-admin. If not set, the impersonation is disabled. Note that site_admin scope is required in the token for the impersonation to work.
  • 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"

Destination token scopes

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.