diff --git a/gitea-action/README.md b/gitea-action/README.md new file mode 100644 index 0000000..bc0816a --- /dev/null +++ b/gitea-action/README.md @@ -0,0 +1,36 @@ +# Deploy via package-updater (composite action) + +Notifies `package-updater` to `docker compose pull` + `up -d` for the matching service(s) after a CI build. + +## Usage + +In a consumer repo's `.gitea/workflows/deploy.yml`: + +```yaml +jobs: + deploy: + runs-on: ubuntu-latest + needs: [build-and-push] + steps: + - uses: gitea.example.com/shcizo/package-updater/gitea-action@v1 + with: + endpoint: https://updater.example.com/update + image: registry.example.com/${{ gitea.repository }} + tag: ${{ gitea.sha }} + token: ${{ secrets.UPDATER_TOKEN }} +``` + +`UPDATER_TOKEN` should be set as an organisation-level secret in Gitea so all repos share it. + +## Inputs + +| Name | Required | Default | Description | +|---|---|---|---| +| `endpoint` | yes | — | Full URL to `/update` | +| `image` | yes | — | Image reference without tag | +| `tag` | no | `""` | Tag that was just pushed (logged for audit) | +| `token` | yes | — | Bearer token configured in package-updater | + +## Failure modes + +The step exits non-zero if `package-updater` returns HTTP 4xx or 5xx. This is intentional — the workflow surfaces the deploy failure to whoever pushed. diff --git a/gitea-action/action.yml b/gitea-action/action.yml new file mode 100644 index 0000000..19148e8 --- /dev/null +++ b/gitea-action/action.yml @@ -0,0 +1,37 @@ +name: "Deploy via package-updater" +description: "Notifies package-updater to pull & restart a Docker Compose service" +inputs: + endpoint: + description: "Full URL to /update (e.g. https://updater.example.com/update)" + required: true + image: + description: "Image reference without tag (e.g. registry.example.com/myapp)" + required: true + tag: + description: "Tag that was just pushed (for logging)" + required: false + default: "" + token: + description: "Bearer token for package-updater" + required: true +runs: + using: "composite" + steps: + - name: Trigger update + shell: bash + env: + TOKEN: ${{ inputs.token }} + run: | + set -euo pipefail + response=$(curl -sS -w "\n%{http_code}" \ + -X POST "${{ inputs.endpoint }}" \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"image\":\"${{ inputs.image }}\",\"tag\":\"${{ inputs.tag }}\"}") + body=$(echo "$response" | head -n -1) + code=$(echo "$response" | tail -n 1) + echo "HTTP $code" + echo "$body" | jq . + if [ "$code" -ge 400 ]; then + exit 1 + fi