Files
siujamo a065745b10 feat(caddy): upload binary to S3
- Upload the compiled binary to any S3-compatible storage via AWS CLI
- Read endpoint, region and bucket from repo variables (S3_ENDPOINT, S3_REGION, S3_BUCKET)
- Skip the upload when S3_BUCKET is unset
- Document the configuration in README
2026-09-02 10:59:40 +08:00

55 lines
1.8 KiB
YAML

name: Build Customised Caddy
on:
workflow_dispatch:
inputs:
caddy_version:
description: 'Specify Caddy version (e.g., latest, v2.8.4)'
required: true
default: 'latest'
caddy_plugin:
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: false
jobs:
build-caddy:
runs-on: ubuntu-latest
steps:
- name: Initialise Go environment
uses: actions/setup-go@v5
with:
go-version: '1.22'
check-latest: true
- name: Install xcaddy programme
run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
- name: Compile customised Caddy binary
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
uses: actions/upload-artifact@v4
with:
name: caddy-custom-linux-amd64
path: caddy
- name: Upload binary to S3
if: ${{ vars.S3_BUCKET != '' }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
AWS_DEFAULT_REGION: ${{ vars.S3_REGION || 'cn-hongkong' }}
run: |
aws configure set default.s3.addressing_style virtual
aws s3 cp caddy "s3://${{ vars.S3_BUCKET }}/caddy-${{ inputs.caddy_version }}-linux-amd64" \
--endpoint-url "${{ vars.S3_ENDPOINT }}" \
--no-progress