Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9c68abf

Browse files
committedNov 18, 2023
explain the app
1 parent 894e193 commit 9c68abf

File tree

1 file changed

+117
-4
lines changed

1 file changed

+117
-4
lines changed
 

‎README.md‎

Lines changed: 117 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# shipit - Stop cloning in your CI!
1+
# shipit - Stop using `git clone` for your deployments
22

33
`shipit` is a tool for committing changes to JSON/YAML files from CI environments to supported Git providers.
44

@@ -10,8 +10,8 @@ GitOps-enabled environments use git repositories to store deployment manifests.
1010

1111
### Git Providers
1212

13-
- Gitea / Forgejo
14-
- GitLab (both self-managed and gitlab.com)
13+
- [Gitea / Forgejo](#gitea--forgejo)
14+
- [GitLab](#gitlab) (both self-managed and gitlab.com)
1515
- (planned) Azure DevOps
1616
- (planned) BitBucket (only BitBucket cloud ie. bitbucket.org)
1717
- (planned) GitHub (both GitHub.com and GitHub Enterprise Server)
@@ -20,12 +20,125 @@ GitOps-enabled environments use git repositories to store deployment manifests.
2020

2121
- JSON (generic)
2222
- YAML (generic)
23-
- Nix
23+
- [Nix](#nix)
2424

2525
## Usage
2626

27+
```
28+
Usage: shipit.exe [OPTIONS]
29+
30+
Options:
31+
-p, --provider <provider> Provider info (as JSON) [env: SHIPIT_PROVIDER=]
32+
-c, --changeset <changes> Changes to apply (as JSON) [env: SHIPIT_CHANGES=]
33+
-a, --author <author> Commit author (as 'name <email>') [env: SHIPIT_AUTHOR=] [default: shipit]
34+
-b, --branch <branch> Branch to commit to [env: SHIPIT_BRANCH=] [default: main]
35+
-m, --message <message> Commit message [env: SHIPIT_MESSAGE=] [default: "Update deployment"]
36+
-h, --help Print help
37+
-V, --version Print version
38+
```
39+
40+
To use shipit you will need to specify a provider and a changeset.
41+
42+
A provider is a Git forge with supported APIs. A changeset is a list of file with the fields that need to be updated. You can specify multiple files in a changeset, each with their own templater (e.g. you can modify both a YAML and JSON file in a single call). shipit will *usually* perform all changes in a single commits but some APIs might only allow one file per commit so make sure to check the description for your provider.
43+
44+
Both provider and changeset are specified as JSON, either via command line or environment variable, like in the following table:
45+
46+
| Parameter | Environment variable | CLI parameter | Format |
47+
| -------------- | -------------------- | --------------- | ---------------------------------------------------------- |
48+
| Provider | SHIPIT_PROVIDER | -p, --provider | `{"provider":<provider id>, ...<provider args>}` |
49+
| Changeset | SHIPIT_CHANGES | -c, --changeset | `[{"templater":<templater id>, ...<templater args>}, ...]` |
50+
| Branch | SHIPIT_BRANCH | -b, --branch | `main` |
51+
| Commit author | SHIPIT_AUTHOR | -a, --author | `Shipit deploy <gitops@example.tld>` |
52+
| Commit message | SHIPIT_MESSAGE | -m, --message | `Updated image tag` |
53+
54+
Every file specified in the changeset **MUST** exist.
55+
56+
### Using providers
57+
58+
#### Gitea / Forgejo
59+
60+
To use Gitea/Forgejo you will need to create an application, go to `<your-instance-url>/user/settings/applications` and generate a new token. Make sure to give it "repository: Read and Write" permissions, then use the following format for the provider parameter:
61+
62+
```json
63+
{
64+
"provider": "gitea",
65+
"api_url": "https://<your-instance-url>/api/v1",
66+
"project_id":"<username>/<repo_name>",
67+
"token": "<username>:<token>"
68+
}
69+
```
70+
71+
#### GitLab
72+
73+
You will need to create an access token, either a project or account (project is probably better). You can find them at: `<your-instance-url>/<username>/<project-id>/-/settings/access_tokens`
74+
75+
The required scopes are `api, write_repository` and the role should be Maintainer, then use the following as your provider parameter:
76+
77+
```json
78+
{
79+
"provider": "gitea",
80+
"api_url": "https://<your-instance-url>/api/v4",
81+
"project_id":"<username>/<repo_name>",
82+
"token": "<token>"
83+
}
84+
```
85+
86+
You can omit `api_url` if you are using Gitlab.com
87+
2788
### Using Templaters
2889

90+
Templaters are change operations that operate on a specific type of file, unlike providers you can specify as many templaters you want in a single call to shipit, for example:
91+
92+
```json
93+
94+
[
95+
{ "templater": "json", "file": "cdk.json", "changes": { "image/tag": "2.0@abcdef" } },
96+
{ "templater": "yaml", "file": "kustomize.yml", "changes": { "image.tag": "2.0@abcdef" } },
97+
]
98+
```
99+
100+
#### JSON
101+
102+
The JSON templater replaces values within a JSON file. Keys are provided as strings using `/` for separation, you can specify array indexes for array (e.g. `nested/field/10/tag` becomes `nested.field[10].tag`).
103+
104+
Your changeset should look like this:
105+
106+
```json
107+
[
108+
{
109+
"templater":"json",
110+
"file":"/path/to/file.json",
111+
"changes":{
112+
"root-field":"new value",
113+
"field/nested/0": "nested value"
114+
}
115+
}
116+
]
117+
```
118+
119+
The fields **MUST** exist in the file or the change will fail.
120+
121+
#### YAML
122+
123+
The YAML templater replaces values within a YAML file. Keys are provided as strings using `.` for separation, you can specify array indexes for array (e.g. `nested.field.10.tag` becomes `nested.field[10].tag`).
124+
125+
Your changeset should look like this:
126+
127+
```json
128+
[
129+
{
130+
"templater":"yaml",
131+
"file":"/path/to/file.json",
132+
"changes":{
133+
"root-field":"new value",
134+
"field.nested.0": "nested value"
135+
}
136+
}
137+
]
138+
```
139+
140+
The fields **MUST** exist in the file or the change will fail.
141+
29142
#### Nix
30143

31144
The Nix templater replaces attributes within a Nix file. Arrays and other field types are not supported.

0 commit comments

Comments
 (0)
Please sign in to comment.