Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ jobs:
steps:
- name: Sync workflow
uses: hostwithquantum/github-org-sync-action@0.5.4
# for templating
env:
PROJECT_EMAIL: oss@planetary-quantum.com"
PROJECT_COMPANY: "Planetary Quantum GmbH"
with:
github-user: ${{ secrets.GH_USER }}
github-email: ${{ secrets.GH_EMAIL }}
github-access-token: ${{ secrets.GH_ACCESS_TOKEN }}
github-repos: ${{ secrets.GH_REPOS }}
github-user: ${{ secrets.GH_USER }}
github-email: ${{ secrets.GH_EMAIL }}
github-access-token: ${{ secrets.GH_ACCESS_TOKEN }}
github-repos: ${{ secrets.GH_REPOS }}
7 changes: 6 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ before:
builds:
- main: ./main.go
binary: github-org-sync
ldflags: -s -w -X main.exporterVersion={{.Version}}
ldflags: -s -w -X main.gitHubActionVersion={{.Version}}
goos:
- darwin
- linux
- windows
ignore:
- goos: darwin
goarch: 386
- goos: windows
goarch: 386
env:
- CGO_ENABLED=0
archives:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM alpine:3.10
FROM alpine:3.12
COPY github-org-sync /github-org-sync
ENTRYPOINT ["/github-org-sync"]
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@

`github-org-sync(-action)` is a tool to sync files from a skeleton/template repository to other repositories in your organization. It works within a single organization, but of course it can be used multiple times.

It currently syncs `.github/workflows` — more is planned.
It currently syncs the following files:

- `.github/workflows`
- `.tpl` (from the root of the repository) (see [Templates](#templates))

And more is (still) planned.

Inspiration from:
- https://github.com/cloudalchemy/auto-maintenance
Expand All @@ -16,7 +21,7 @@ https://github.com/hostwithquantum/github-org-sync-action/actions?query=workflow

## GitHub Action

This _Action_ is meant to run on a schedule, see the "sync" workflow (`.github/workflows/sync.yml`) in this repository for a minimal demo/working example.
This _Action_ is meant to run on a schedule, see [the "sync" workflow (`.github/workflows/sync.yml`)](https://github.com/hostwithquantum/blob/main/.github/workflows/sync.yml) in this repository for a minimal demo/working example.

### Inputs

Expand Down Expand Up @@ -61,13 +66,39 @@ To use the Docker image, please follow one of these links:
- https://quay.io/repository/hostwithquantum/github-org-sync?tab=tags
- https://github.com/hostwithquantum/github-org-sync-action/packages

Otherwise: `make dev` to build a snapshot.
Otherwise:
- install goreleaser
- `make dev` to build a snapshot

#### Configuration

- `github-org-sync` uses environment variables. There is nothing else currently.
- See [.envrc-dist](.envrc-dist) for necessary configuration.
- Please note that, `GITHUB_ACCESS_TOKEN` **requires** full repo scope, in order to create branches, push them and open pull-requests.
- `github-org-sync` uses environment variables
- see [.envrc-dist](.envrc-dist) for necessary configuration
- `GITHUB_ACCESS_TOKEN` **requires** full repo scope on your organization (in order to create branches, push them and open pull-requests)

#### Templates

The `.tpl` files in your repository _can_ be templates:
- `LICENSE.tpl`
- `CONTRIBUTION.md.tpl`
- etc. ...

For templating we use [gucci](https://github.com/noqcks/gucci) (which uses Golang's [text/template](https://golang.org/pkg/text/template/) and [sprig](https://masterminds.github.io/sprig/) functions). If gucci supports it, it is available to customize the files prior to committing them to the repository.

Variables used inside templates must be in the environment (see exceptions). For example, to customize your license template with the current year and your company's name:

```
# license.tpl
Copyrigth {{ now | date "2006" }} by {{ .PROJECT_COMPANY }}
```

The year is injected by using sprig functions, the `.PROJECT_COMPANY` is replaced by an environment variable called `PROJECT_COMPANY`.

Exceptions/Caveats:
- `{{ .GITHUB_REPOSITORY }}` variable is generated by this tool at your convenience
- gucci provides a mechanism to read the environment, so sprig's environment magic is not available

_An example of templates can be found by looking at the [sync workflow](https://github.com/hostwithquantum/github-org-sync-action/blob/main/.github/workflows/sync.yml) in this repository._

# Author

Expand Down
18 changes: 17 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@ module github.com/hostwithquantum/github-org-sync-action
go 1.13

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/go-git/go-git/v5 v5.1.0
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/noqcks/gucci v0.4.0
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.6.0
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)

// branch: gucci-library
replace github.com/noqcks/gucci v0.4.0 => github.com/till/gucci v0.0.5-0.20200711190254-ff5213d61a32
Loading