124 lines
5.0 KiB
Markdown
124 lines
5.0 KiB
Markdown
# pipeline-actions
|
|
|
|
Reusable composite actions for Gitea Actions CI/CD pipelines in the homelab.
|
|
|
|
## Actions
|
|
|
|
### `build-and-push`
|
|
|
|
Builds and pushes a multi-architecture Docker image using a remote Buildx builder over SSH.
|
|
|
|
```yaml
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-amd64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://git.ivanch.me/ivanch/pipeline-actions/build-and-push@main
|
|
with:
|
|
image: git.ivanch.me/ivanch/my-app
|
|
registry_password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
ssh_key: ${{ secrets.SSH_KEY_DOCKERBUILD }}
|
|
# optional — these have sensible defaults:
|
|
# image_tag: latest
|
|
# registry_host: git.ivanch.me
|
|
# registry_username: ivanch
|
|
# platforms: linux/amd64,linux/arm64
|
|
# build_context: .
|
|
# build_dockerfile: Dockerfile
|
|
# docker_host: docker-build.haven
|
|
# docker_user: root
|
|
```
|
|
|
|
| Input | Required | Default | Description |
|
|
|---|---|---|---|
|
|
| `image` | ✅ | — | Full image reference without tag |
|
|
| `registry_password` | ✅ | — | Registry password/token (use secrets) |
|
|
| `ssh_key` | ✅ | — | SSH private key for the remote builder (use secrets) |
|
|
| `image_tag` | ❌ | `latest` | Comma-separated tag(s) to apply to the built image (e.g. `latest,abc1234`). Pushing a commit-pinned tag alongside `:latest` is how Docker-only deploys consume per-commit tags. |
|
|
| `registry_host` | ❌ | `git.ivanch.me` | Container registry hostname |
|
|
| `registry_username` | ❌ | `ivanch` | Registry username |
|
|
| `platforms` | ❌ | `linux/amd64,linux/arm64` | Target build platforms |
|
|
| `build_context` | ❌ | `.` | Docker build context |
|
|
| `build_dockerfile` | ❌ | `Dockerfile` | Dockerfile path |
|
|
| `docker_host` | ❌ | `docker-build.haven` | Remote builder hostname |
|
|
| `docker_user` | ❌ | `root` | SSH user for remote builder |
|
|
|
|
---
|
|
|
|
### `deploy-restart`
|
|
|
|
Validates a kubeconfig, installs kubectl, and performs a `rollout restart` of a Kubernetes Deployment.
|
|
|
|
```yaml
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-amd64
|
|
needs: build
|
|
steps:
|
|
- uses: https://git.ivanch.me/ivanch/pipeline-actions/deploy-restart@main
|
|
with:
|
|
kube_config: ${{ secrets.KUBE_CONFIG }}
|
|
deployment_name: my-app
|
|
# optional:
|
|
# namespace: default
|
|
# kube_version: stable
|
|
```
|
|
|
|
| Input | Required | Default | Description |
|
|
|---|---|---|---|
|
|
| `kube_config` | ✅ | — | Full kubeconfig YAML (use secrets) |
|
|
| `deployment_name` | ✅ | — | Deployment name to restart |
|
|
| `namespace` | ❌ | `default` | Kubernetes namespace |
|
|
| `kube_version` | ❌ | `stable` | kubectl version (`stable` or e.g. `v1.31.0`) |
|
|
|
|
### `ssh-deploy`
|
|
|
|
SSH into a remote host and run `docker compose pull` + `docker compose up -d --force-recreate` to deploy the latest images. No third-party SSH action — uses native `ssh` and `ssh-keyscan`.
|
|
|
|
```yaml
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-amd64
|
|
needs: build
|
|
steps:
|
|
- uses: https://git.ivanch.me/ivanch/pipeline-actions/ssh-deploy@main
|
|
with:
|
|
ssh_host: ${{ secrets.DEPLOY_HOST }}
|
|
ssh_username: ${{ secrets.DEPLOY_USERNAME }}
|
|
ssh_key: ${{ secrets.DEPLOY_KEY }}
|
|
remote_dir: ${{ secrets.DEPLOY_DIR }}
|
|
# optional:
|
|
# ssh_port: "22"
|
|
# compose_files: docker-compose.yml compose.override.yml
|
|
# image: git.ivanch.me/ivanch/my-app # pins matching services
|
|
# image_tag: latest # Docker-only custom tag
|
|
```
|
|
|
|
| Input | Required | Default | Description |
|
|
|---|---|---|---|
|
|
| `ssh_host` | ✅ | — | Remote server hostname or IP |
|
|
| `ssh_username` | ✅ | — | SSH username |
|
|
| `ssh_key` | ✅ | — | SSH private key (use secrets) |
|
|
| `remote_dir` | ✅ | — | Directory on the remote server with `docker-compose.yml` |
|
|
| `ssh_port` | ❌ | `22` | SSH port |
|
|
| `compose_files` | ❌ | _(empty)_ | Space-separated compose file paths (applied via `-f` flags; when empty docker compose uses default detection) |
|
|
| `image` | ❌ | _(empty)_ | Image base (host/path/name, **without tag**). When set, every compose service whose image matches this base is pinned to `image_tag` at deploy time. **Docker-only** — k8s deploys use `deploy-restart`, not this. |
|
|
| `image_tag` | ❌ | `latest` | Tag applied to `image` when `image` is set. (Single tag — comma-lists are not supported for deploys.) |
|
|
|
|
---
|
|
|
|
## Required Secrets
|
|
|
|
Consumer repositories need these secrets configured in Gitea:
|
|
|
|
| Secret | Used by | Purpose |
|
|
|---|---|---|
|
|
| `REGISTRY_PASSWORD` | `build-and-push` | Container registry password/token |
|
|
| `SSH_KEY_DOCKERBUILD` | `build-and-push` | SSH private key for `docker-build.haven` |
|
|
| `KUBE_CONFIG` | `deploy-restart` | Full kubeconfig YAML for cluster access |
|
|
| `DEPLOY_HOST` | `ssh-deploy` | Remote server hostname or IP |
|
|
| `DEPLOY_USERNAME` | `ssh-deploy` | SSH username for the remote server |
|
|
| `DEPLOY_KEY` | `ssh-deploy` | SSH private key for the remote server |
|
|
| `DEPLOY_DIR` | `ssh-deploy` | Directory on the remote server with `docker-compose.yml` |
|