ci: migrate caddy build to GitHub Actions
- Move build-caddy workflow from Gitea to GitHub Actions - Make caddy_plugin optional, supporting comma-separated plugins - Add README documenting workflow usage
This commit is contained in:
2 files changed
+72
-4
No files matched your search
@@ -8,9 +8,8 @@ on:
|
|||||||
required: true
|
required: true
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
caddy_plugin:
|
caddy_plugin:
|
||||||
description: 'Specify plugin module path (e.g., github.com/caddy-dns/cloudflare)'
|
description: 'Comma-separated plugin module paths, e.g. github.com/caddy-dns/cloudflare, github.com/caddyserver/nginx-adapter. Leave empty to build vanilla Caddy.'
|
||||||
required: true
|
required: false
|
||||||
default: 'github.com/caddy-dns/cloudflare'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-caddy:
|
build-caddy:
|
||||||
@@ -26,7 +25,16 @@ jobs:
|
|||||||
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
||||||
|
|
||||||
- name: Compile customised Caddy binary
|
- name: Compile customised Caddy binary
|
||||||
run: xcaddy build ${{ inputs.caddy_version }} --with ${{ inputs.caddy_plugin }}
|
run: |
|
||||||
|
PLUGIN_ARGS=""
|
||||||
|
IFS=',' read -ra PLUGINS <<< "${{ inputs.caddy_plugin }}"
|
||||||
|
for PLUGIN in "${PLUGINS[@]}"; do
|
||||||
|
PLUGIN="${PLUGIN// /}"
|
||||||
|
if [ -n "$PLUGIN" ]; then
|
||||||
|
PLUGIN_ARGS="$PLUGIN_ARGS --with $PLUGIN"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
xcaddy build ${{ inputs.caddy_version }} $PLUGIN_ARGS
|
||||||
|
|
||||||
- name: Upload compiled artefact
|
- name: Upload compiled artefact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# infra
|
||||||
|
|
||||||
|
The infrastructure repository of onixbyte, hosting the CI workflows used to build and maintain the runtime environment.
|
||||||
|
|
||||||
|
## Directory structure
|
||||||
|
|
||||||
|
```
|
||||||
|
infra/
|
||||||
|
└── .github/workflows/
|
||||||
|
└── build-caddy.yaml # GitHub Actions workflow that builds a customised Caddy binary
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building a customised Caddy
|
||||||
|
|
||||||
|
The `build-caddy.yaml` workflow uses [xcaddy](https://github.com/caddyserver/xcaddy) to compile a specified version of Caddy with plugins injected, and uploads the compiled binary as an artefact. The workflow can only be triggered manually.
|
||||||
|
|
||||||
|
### How to trigger the build
|
||||||
|
|
||||||
|
1. Open the **Actions** page of the repository.
|
||||||
|
2. Select the **Build Customised Caddy** workflow from the left-hand panel.
|
||||||
|
3. Click **Run workflow** and fill in the parameters (see the table below).
|
||||||
|
4. Wait for the build to finish, then download the `caddy-custom-linux-amd64` artefact from the build run page.
|
||||||
|
|
||||||
|
### Input parameters
|
||||||
|
|
||||||
|
| Parameter | Description | Required | Default |
|
||||||
|
|-----------|-------------|:---:|---------|
|
||||||
|
| `caddy_version` | Caddy version to build, e.g. `latest`, `v2.8.4` | Yes | `latest` |
|
||||||
|
| `caddy_plugin` | Comma-separated plugin module paths, e.g. `github.com/caddy-dns/cloudflare, github.com/caddyserver/nginx-adapter`. Leave empty to build vanilla Caddy. | No | — |
|
||||||
|
|
||||||
|
### Plugin input behaviour
|
||||||
|
|
||||||
|
The table below shows how the value of `caddy_plugin` maps to the actual `xcaddy` command (using the default `latest` version):
|
||||||
|
|
||||||
|
| Input (`caddy_plugin`) | Command that runs |
|
||||||
|
|------------------------|-------------------|
|
||||||
|
| `github.com/caddy-dns/cloudflare, github.com/caddyserver/nginx-adapter` | `xcaddy build latest --with github.com/caddy-dns/cloudflare --with github.com/caddyserver/nginx-adapter` |
|
||||||
|
| `github.com/caddy-dns/cloudflare,github.com/caddyserver/nginx-adapter` | Same as above (spaces are optional) |
|
||||||
|
| `github.com/caddy-dns/cloudflare` | `xcaddy build latest --with github.com/caddy-dns/cloudflare` |
|
||||||
|
| *(empty)* | `xcaddy build latest` (vanilla Caddy) |
|
||||||
|
|
||||||
|
> Empty entries are skipped automatically, so `plugin1, , plugin2` behaves the same as `plugin1, plugin2`.
|
||||||
|
|
||||||
|
## Building locally
|
||||||
|
|
||||||
|
To reproduce the same build on your own machine you need Go 1.22+:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
|
||||||
|
|
||||||
|
# Compile a specific version with a plugin injected
|
||||||
|
xcaddy build v2.8.4 --with github.com/caddy-dns/cloudflare
|
||||||
|
|
||||||
|
# Inject several plugins at once
|
||||||
|
xcaddy build latest \
|
||||||
|
--with github.com/caddy-dns/cloudflare \
|
||||||
|
--with github.com/caddyserver/nginx-adapter
|
||||||
|
```
|
||||||
|
|
||||||
|
When the build finishes, an executable named `caddy` is produced in the current directory.
|
||||||
Reference in new issue
Block a user