16 Commits

Author SHA1 Message Date
Anthony Sterling
bc20d5071b Release 202008101504
Some checks failed
goreleaser / goreleaser (push) Has been cancelled
2020-08-10 15:04:52 +01:00
Anthony Sterling
27d5069550 Merge pull request #6 from chrisgavin/fix-incorrect-message
Fix some incorrect error messages.
2020-08-10 14:51:08 +01:00
Anthony Sterling
8cdfdec64a Merge pull request #7 from chrisgavin/fix-cache-dir-not-required
Fix `--cache-dir` not actually being marked as a required flag.
2020-08-10 14:50:50 +01:00
Chris Gavin
732ce15227 Fix some incorrect error messages. 2020-08-06 15:03:38 +01:00
Chris Gavin
7f01c4dc4d Fix --cache-dir not actually being marked as a required flag. 2020-08-06 14:58:30 +01:00
Anthony Sterling
282f386ced Release 202007141234
Some checks failed
goreleaser / goreleaser (push) Has been cancelled
2020-07-14 12:34:54 +01:00
Anthony Sterling
cf3d098c7a Merge pull request #5 from actions/remove-master-from-tests
Remove references to master from tests
2020-07-14 12:33:53 +01:00
Anthony Sterling
71a43cffca update test docs to refer to main 2020-07-14 12:28:33 +01:00
Anthony Sterling
735b1d3c28 rename master to main in build tests 2020-07-14 12:27:39 +01:00
Anthony Sterling
61c2f4ac26 Release 202007131324
Some checks failed
goreleaser / goreleaser (push) Has been cancelled
2020-07-13 13:24:50 +01:00
Anthony Sterling
c6f5906aa1 add nil check for create repo response 2020-07-13 13:24:20 +01:00
Andy McKay
216045d0eb Update README.md
Less words, less grammar errors.
2020-07-09 10:59:29 -07:00
Andy McKay
de2c7907a1 Update README.md 2020-07-08 15:39:53 -07:00
Andy McKay
162e340368 Merge pull request #3 from actions/improve-readme.png
Update the readme a bit
2020-07-08 15:39:01 -07:00
Andy McKay
dc659980cd update the readme a bit 2020-07-08 14:50:49 -07:00
Andy McKay
1f37634adc Update ci.yml 2020-07-08 14:42:52 -07:00
9 changed files with 77 additions and 64 deletions

View File

@@ -1,6 +1,7 @@
name: CI
on:
pull_request:
workflow_dispatch:
jobs:
CI:
runs-on: ubuntu-latest

View File

@@ -1,4 +1,4 @@
project_name: actions-sync
project_name: gh
builds:
- <<: &build_defaults

View File

@@ -1,10 +1,22 @@
# actions-sync
# Actions Sync
Sync GitHub Action repositories from https://www.github.com to your GHES instance.
<p align="center">
<img src="docs/arrow.png">
</p>
## Non air-gapped GHES instances
This is a standalone Go tool to allow you to sync from [GitHub](https://www.github.com) to a [GitHub Enterprise instance](https://github.com/enterprise). GitHub Enterprise is referred to as `GHES` throughout this document.
When there are machines which have access to both the public interenet and the the GHES instance run `actions-sync sync`.
* Current status: **ready for production use**
* Download from: [releases page](https://github.com/actions/actions-sync/releases/)
* Build status: ![Actions Sync Status](https://github.com/actions/actions-sync/workflows/CI/badge.svg)
It is designed to work when:
* The GitHub Enterprise instance is seperate from the rest of the internet.
* The GitHub Enterprise instance is connected to the rest of the internet.
## Connected instances
When there are machines which have access to both the public internet and the GHES instance run `actions-sync sync`.
**Command:**
@@ -35,7 +47,7 @@ When there are machines which have access to both the public interenet and the t
--repo-name actions/setup-node
```
## Air-gapped GHES instances
## Not connected instances
When no machine has access to both the public internet and the GHES instance:

View File

@@ -86,7 +86,7 @@ var (
func Execute(ctx context.Context) error {
rootCmd.PersistentFlags().StringVar(&cacheDir, "cache-dir", "", "Directory containing the repopositories cache created by the `pull` command")
_ = rootCmd.MarkFlagRequired("cache-dir")
_ = rootCmd.MarkPersistentFlagRequired("cache-dir")
rootCmd.AddCommand(versionCmd)

BIN
docs/arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -21,34 +21,34 @@ trap "after_suite" SIGINT
function test_pull() {
# Pull new repo
setup_src "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_src "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache
pull --repo-name "org/repo" "pulling new repo"
assert_cache_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "pulling new repo org/repo"
assert_cache_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "pulling new repo org/repo"
echo "all pull tests passed successfully"
}
function test_push() {
# Push with a new change to master
setup_cache "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
# Push with a new change to main
setup_cache "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
push "pushing new commit to master"
assert_dest_sha "org/repo" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org/repo:heads/master to new commit"
push "pushing new commit to main"
assert_dest_sha "org/repo" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org/repo:heads/main to new commit"
# Push a non-linear change
setup_cache "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_cache "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
push "pushing to an old commit to master"
assert_dest_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "updating heads/master to an old commit"
push "pushing to an old commit to main"
assert_dest_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "updating heads/main to an old commit"
# Push with no changes to master
setup_cache "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
push "pushing no changes to master"
assert_dest_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "leaving org/repo:heads/master at existing commit"
# Push with no changes to main
setup_cache "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
push "pushing no changes to main"
assert_dest_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "leaving org/repo:heads/main at existing commit"
# Push multiple branches
setup_cache "org/repo:heads/change:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
@@ -61,86 +61,86 @@ function test_push() {
assert_dest_sha "org/repo" "heads/nochange" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "leaving org/repo:heads/nochange at existing commit"
# Pushing multiple branches and tags
setup_cache "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
setup_cache "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
"org/repo:tags/v1:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
"org/repo:tags/v1:a5984bb887dd2fcdc2892cd906d6f004844d1142"
push "pushing multiple branches and tags"
assert_dest_sha "org/repo" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org/repo:heads/master to new commit"
assert_dest_sha "org/repo" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org/repo:heads/main to new commit"
assert_dest_sha "org/repo" "tags/v1" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org/repo:tags/v1 to new commit"
# Pushing multiple repositories
setup_cache "org1/repo1:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
"org1/repo2:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
setup_cache "org1/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
"org1/repo2:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
"org1/repo2:tags/v1:e9009d51dd6da2c363d1d14779c53dd27fcb0c52" \
"org2/repo1:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org1/repo1:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
"org1/repo2:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
"org2/repo1:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org1/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
"org1/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
"org1/repo2:tags/v1:a5984bb887dd2fcdc2892cd906d6f004844d1142" \
"org2/repo1:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
"org2/repo1:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
push "pushing multiple repositories"
assert_dest_sha "org1/repo1" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org1/repo1:heads/master to new commit"
assert_dest_sha "org1/repo2" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org1/repo2:heads/master to new commit"
assert_dest_sha "org1/repo1" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org1/repo1:heads/main to new commit"
assert_dest_sha "org1/repo2" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org1/repo2:heads/main to new commit"
assert_dest_sha "org1/repo2" "tags/v1" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org1/repo2:tags/v1 to new commit"
assert_dest_sha "org2/repo1" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org2/repo1:tags/v1 to new commit"
assert_dest_sha "org2/repo1" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "updating org2/repo1:tags/v1 to new commit"
echo "all push tests passed successfully"
}
function test_sync() {
# Sync no change without cached
setup_src "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_src "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
sync --repo-name "org/repo" "syncing a new commit in an uncached repo"
assert_dest_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing no changes without cache"
assert_dest_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing no changes without cache"
# Sync a new commit without cache
setup_src "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_src "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_cache
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
sync --repo-name "org/repo" "syncing a new commit in an uncached repo"
assert_dest_sha "org/repo" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "syncing a new commit without cache"
assert_dest_sha "org/repo" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "syncing a new commit without cache"
# Sync no change with uncached
setup_src "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_src "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
sync --repo-name "org/repo" "syncing a new commit in an uncached repo"
assert_dest_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing no changes with cache"
assert_dest_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing no changes with cache"
# Sync a new commit with cache
setup_src "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_cache "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_src "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_cache "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
sync --repo-name "org/repo" "syncing a new commit in an uncached repo"
assert_dest_sha "org/repo" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "syncing a new commit with cache"
assert_dest_sha "org/repo" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "syncing a new commit with cache"
# Sync a non-linear change without cache
setup_src "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_src "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache
setup_dest "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
sync --repo-name "org/repo" "syncing an old commit in an uncached repo"
assert_dest_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing heads/master to an old commit without cache"
assert_dest_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing heads/main to an old commit without cache"
# Sync a non-linear change with cache
setup_src "org/repo:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_src "org/repo:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_cache "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_dest "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
sync --repo-name "org/repo" "syncing an old commit in an cached repo"
assert_dest_sha "org/repo" "heads/master" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing heads/master to an old commit with cache"
assert_dest_sha "org/repo" "heads/main" "a5984bb887dd2fcdc2892cd906d6f004844d1142" "syncing heads/main to an old commit with cache"
# Sync to a different repo
setup_src "org/repo:heads/master:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_src "org/repo:heads/main:e9009d51dd6da2c363d1d14779c53dd27fcb0c52"
setup_cache
setup_dest "org2/repo2:heads/master:a5984bb887dd2fcdc2892cd906d6f004844d1142"
setup_dest "org2/repo2:heads/main:a5984bb887dd2fcdc2892cd906d6f004844d1142"
sync --repo-name "org/repo:org2/repo2" "syncing org/repo aliased to org2/repo2"
assert_dest_sha "org2/repo2" "heads/master" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "syncing org/repo aliased to org2/repo2"
assert_dest_sha "org2/repo2" "heads/main" "e9009d51dd6da2c363d1d14779c53dd27fcb0c52" "syncing org/repo aliased to org2/repo2"
echo "all sync tests passed successfully"
}

View File

@@ -34,7 +34,7 @@ func (f *PullFlags) Init(cmd *cobra.Command) {
func (f *PullFlags) Validate() Validations {
var validations Validations
if !f.HasAtLeastOneRepoFlag() {
validations = append(validations, "one of -repo-name, -repo-name-list, -repo-name-list-file must be set")
validations = append(validations, "one of --repo-name, --repo-name-list, --repo-name-list-file must be set")
}
return validations
}

View File

@@ -30,10 +30,10 @@ func (f *PushFlags) Init(cmd *cobra.Command) {
func (f *PushFlags) Validate() Validations {
var validations Validations
if f.BaseURL == "" {
validations = append(validations, "-baseURL must be set")
validations = append(validations, "--destination-url must be set")
}
if f.Token == "" {
validations = append(validations, "-token must be set")
validations = append(validations, "--destination-token must be set")
}
return validations
}
@@ -93,7 +93,7 @@ func getOrCreateGitHubRepo(ctx context.Context, client *github.Client, repoName,
HasProjects: github.Bool(false),
}
ghRepo, resp, err := client.Repositories.Create(ctx, orgName, repo)
if resp.StatusCode == 422 {
if resp != nil && resp.StatusCode == 422 {
ghRepo, _, err = client.Repositories.Get(ctx, orgName, repoName)
}
if err != nil {

View File

@@ -1 +1 @@
ref: refs/heads/master
ref: refs/heads/main