2022-09-18 21:07:07 +02:00
|
|
|
<p align="center">
|
2022-09-21 11:06:53 +02:00
|
|
|
<image src="https://git.front.kjuulh.io/kjuulh/octopush/raw/branch/v0.2/assets/octopush.svg" width="300" height="300"/>
|
2022-09-18 21:07:07 +02:00
|
|
|
</p>
|
2022-09-21 11:06:53 +02:00
|
|
|
<h1 align="center">Octopush - Your cute action executor</h1>
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
## Purpose
|
|
|
|
|
2022-09-18 21:15:13 +02:00
|
|
|
The goal of this project is to easily do batch changes or queries on a host of
|
2022-09-18 21:07:07 +02:00
|
|
|
repositories. In large organisations using multi-repository strategies, it may
|
2022-09-18 21:15:13 +02:00
|
|
|
be painful to change even small things across many repositories, because there
|
2022-09-21 11:06:53 +02:00
|
|
|
are so many of them. Octopush aims to change that.
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
**DISCLAIMER:** It is still early days, and the api is subject to change.
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
2022-09-18 21:16:05 +02:00
|
|
|
- Uses an actions repository, where you store all your pending commands or
|
|
|
|
queries to be performed across your fleet of repositories. (See \_examples)
|
2022-09-18 21:07:07 +02:00
|
|
|
- Actions can both execute changes, open pull-requests or in some cases commit
|
|
|
|
directly to your preferred branch
|
|
|
|
- Actions natively use either shell, go or docker files to execute changes
|
|
|
|
(see \_examples/actions)
|
|
|
|
- Actions can also be analytical, so you can query your fleet for whatever you
|
|
|
|
would like
|
|
|
|
- Works both as a client, or as a server
|
|
|
|
- Supports SSH/https for fetching repos
|
|
|
|
- Supports GPG signing
|
|
|
|
- Supports dry-run mode for easy testing when developing your actions (enabled
|
|
|
|
by default on the cli)
|
|
|
|
|
|
|
|
## Roadmap
|
|
|
|
|
|
|
|
Refer to [roadmap.md](roadmap.md)
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
Octopush comes in two modes. Client or Client -> Server. Octopush can stand alone as
|
2022-09-18 21:07:07 +02:00
|
|
|
a client, for smaller and less secure changes. However, for organisations, it
|
2022-09-21 11:06:53 +02:00
|
|
|
may be useful to use Octopush in server mode, which supports more features, and
|
2022-09-18 21:07:07 +02:00
|
|
|
has extra security built in.
|
|
|
|
|
|
|
|
### Client (CLI)
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
Download executable from [releases](https://github.com/kjuulh/octopush/releases)
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
#### Or Use docker image
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
docker run --rm kasperhermansen/octopushcli:latest version
|
2022-09-18 21:07:07 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Or Build from source
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
git clone https://github.com/kjuulh/octopush.git
|
|
|
|
cd octopush
|
2022-09-18 21:07:07 +02:00
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
go build cmd/octopush/octopush.go
|
|
|
|
./octopush version
|
2022-09-18 21:07:07 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Or Build with cuddle
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
git clone https://github.com/kjuulh/octopush.git
|
|
|
|
cd octopush
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
cuddle_cli x build_cli
|
|
|
|
```
|
|
|
|
|
|
|
|
### Server
|
|
|
|
|
|
|
|
We prefer to run the server directly as a docker image.
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
docker pull kasperhermansen/octopushserver:latest
|
|
|
|
docker run -p 9090:80 --rm kasperhermansen/octopushserver:latest
|
2022-09-18 21:07:07 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
#### Or Build from source
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
git clone https://github.com/kjuulh/octopush.git
|
|
|
|
cd octopush
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
go build cmd/server/server.go
|
|
|
|
./server version
|
|
|
|
```
|
|
|
|
|
|
|
|
#### Or Build with cuddle
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
git clone https://github.com/kjuulh/octopush.git
|
|
|
|
cd octopush
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
cuddle_cli x build_server
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
**DISCLAIMER:** It is still early days, and the api of the CLI is subject to
|
|
|
|
change, this provides the aim of the project, but as it is currently in flux,
|
|
|
|
there may not be as much handholding in the actual usage.
|
|
|
|
|
|
|
|
I will focus on the client here, as the server provides the same features,
|
|
|
|
though available through the cli, but instead as configuration options (see
|
|
|
|
[CONFIGURATION_SERVER.md](CONFIGURATION_SERVER.md))
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
Octopush ships with autocomplete built in (courtesy of spf13/cobra). To add:
|
2022-09-18 21:07:07 +02:00
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
- Bash: `echo 'source <(octopush completion bash)' >> ~/.bashrc`
|
|
|
|
- Zsh: `echo 'source <(octopush completion zsh)' >> ~/.zshrc`
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
### Creating a new action
|
|
|
|
|
|
|
|
Creating a new action
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git init my-actions # should only be done once
|
|
|
|
cd my-actions
|
2022-09-21 11:06:53 +02:00
|
|
|
octopush tmpl init write-a-readme --command
|
|
|
|
cat write-a-readme/octopush.yml
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
# Output
|
2022-09-21 11:06:53 +02:00
|
|
|
# apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
2022-09-18 21:07:07 +02:00
|
|
|
# name: write-a-readme
|
|
|
|
# select:
|
|
|
|
# repositories: []
|
|
|
|
# actions:
|
|
|
|
# - type: shell
|
|
|
|
# entry: "main.sh"
|
|
|
|
```
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
Octopush also ships with yaml schema, which should help write the yaml
|
2022-09-18 21:07:07 +02:00
|
|
|
configuration.
|
|
|
|
|
|
|
|
#### Add upstream repositories (victims)
|
|
|
|
|
|
|
|
Now add a preferred repository
|
|
|
|
|
|
|
|
```
|
2022-09-21 11:06:53 +02:00
|
|
|
cat << EOF > write-a-readme/octopush.yml
|
|
|
|
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
2022-09-18 21:07:07 +02:00
|
|
|
name: write-a-readme
|
|
|
|
select:
|
|
|
|
providers: # new
|
|
|
|
- gitea: https://git.front.kjuulh.io # new
|
|
|
|
organisation: "kjuulh" # new
|
|
|
|
actions:
|
|
|
|
- type: shell
|
|
|
|
entry: "main.sh"
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
This will take all your repositories under an organisation and run the script
|
|
|
|
on.
|
|
|
|
|
|
|
|
Another could be to use
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
cat << EOF > write-a-readme/octopush.yml
|
|
|
|
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
2022-09-18 21:07:07 +02:00
|
|
|
name: write-a-readme
|
|
|
|
select:
|
|
|
|
repositories: #new
|
2022-09-21 11:06:53 +02:00
|
|
|
- git@git.front.kjuulh.io:kjuulh/octopush.git #new
|
|
|
|
- git@git.front.kjuulh.io:kjuulh/octopush-test.git #new
|
2022-09-18 21:07:07 +02:00
|
|
|
actions:
|
|
|
|
- type: shell
|
|
|
|
entry: "main.sh"
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
This will just apply to those repositories instead. Both can also be combined
|
|
|
|
for a shared effect.
|
|
|
|
|
|
|
|
### Execute action
|
|
|
|
|
|
|
|
To run the script use
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
octopush process --path "write-a-readme"
|
2022-09-18 21:07:07 +02:00
|
|
|
```
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
This will cause the octopush process to automatically apply the action on the repo
|
2022-09-18 21:07:07 +02:00
|
|
|
and open a pr.
|
|
|
|
|
|
|
|
### Query repositories
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
Octopush can also be used to query.
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
cat << EOF > write-a-readme/octopush.yml
|
|
|
|
apiVersion: git.front.kjuulh.io/kjuulh/octopush/blob/main/schema/v1
|
2022-09-18 21:07:07 +02:00
|
|
|
name: write-a-readme
|
|
|
|
select:
|
|
|
|
repositories:
|
2022-09-21 11:06:53 +02:00
|
|
|
- git@git.front.kjuulh.io:kjuulh/octopush.git
|
|
|
|
- git@git.front.kjuulh.io:kjuulh/octopush-test.git
|
2022-09-18 21:07:07 +02:00
|
|
|
queries:
|
|
|
|
- type: grep
|
|
|
|
query: "# README"
|
|
|
|
EOF
|
|
|
|
```
|
|
|
|
|
|
|
|
Using the same command as above, will return the lines on each repo with those
|
|
|
|
criteria. Everything is run in docker, even locally, so no need to install fancy
|
|
|
|
tools.
|
|
|
|
|
|
|
|
Do note: All actions will be run as dry-run unless `--apply` is added. This is
|
|
|
|
to help test locally, as well as not cause serious issues. The server
|
|
|
|
configuration is pretty much the same, except the command would look like so:
|
2022-09-21 11:06:53 +02:00
|
|
|
`octopush server process --path "write-a-readme" --apply`. Octopush will try to
|
2022-09-18 21:07:07 +02:00
|
|
|
infer as much as possible, but it may be needed to apply some extra flags to
|
2022-09-21 11:06:53 +02:00
|
|
|
specify upstream repositories and such. Octopush will also help you setup keys and
|
|
|
|
such on the first run, using `octopush setup` or `octopush server setup`.
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
## Contributing
|
|
|
|
|
|
|
|
It is still early days, and as such things are moving fast, I may not be able to
|
|
|
|
implement features, because I am focusing my energy on the API. That said PRs
|
|
|
|
are welcome, though they are at your own risk.
|
|
|
|
|
|
|
|
### Bugs & features requests
|
|
|
|
|
2022-09-21 11:06:53 +02:00
|
|
|
Please use [issues](https://github.com/kjuulh/octopush/issues)
|
2022-09-18 21:07:07 +02:00
|
|
|
|
|
|
|
### Development
|
|
|
|
|
|
|
|
We use [cuddle](https://git.front.kjuulh.io/kjuulh/cuddle) to improve ease of
|
|
|
|
use, it is however, not a requirement, and probably won't need to be used
|
|
|
|
outside core maintainers.
|
|
|
|
|
|
|
|
Simply:
|
|
|
|
|
|
|
|
```bash
|
2022-09-21 11:06:53 +02:00
|
|
|
go run cmd/octopush/octopush.go # CLI
|
2022-09-18 21:07:07 +02:00
|
|
|
go run cmd/server/server.go # Server
|
|
|
|
```
|
|
|
|
|
|
|
|
We follow the `gofmt` formatting, along with optionally but recommend `golines`
|
|
|
|
|
|
|
|
If using cuddle
|
|
|
|
|
|
|
|
```
|
|
|
|
cuddle_cli x run # Run both server and client, will do a quick test sweep on the cli
|
|
|
|
cuddle_cli x watch_run # Automatically refresh both
|
|
|
|
cuddle_cli x fmt # will format the current code
|
|
|
|
```
|