workflows/gitops-bump/action.yaml

40 lines
1.5 KiB
YAML

name: gitops-bump
description: >
Points the app's kustomize overlay in the gitops repo at the image tag
just pushed (short sha of the triggering commit); ArgoCD picks up the
commit and deploys. Run on the `host` runner label (git + kustomize
installed there).
inputs:
app-name:
description: App name (dir under manifests/ and kustomize image name)
required: true
gitops-repo:
description: owner/name of the gitops repo
required: false
default: nholtware/gitops
gitops-token:
description: Token with write access to the gitops repo (pass secrets.GITOPS_TOKEN)
required: true
registry:
description: Registry host:port (must match build-push)
required: false
default: "192.168.1.230:3000"
runs:
using: composite
steps:
- shell: bash
env:
GITOPS_TOKEN: ${{ inputs.gitops-token }}
run: |
set -euo pipefail
TAG="${GITHUB_SHA:0:8}"
IMAGE="${{ inputs.registry }}/$GITHUB_REPOSITORY_OWNER/${{ inputs.app-name }}"
DIR="$(mktemp -d)"
trap 'rm -rf "$DIR"' EXIT
git clone --depth 1 "http://ci-bot:${GITOPS_TOKEN}@192.168.1.230:3000/${{ inputs.gitops-repo }}.git" "$DIR"
cd "$DIR/manifests/${{ inputs.app-name }}"
kustomize edit set image "${{ inputs.app-name }}=$IMAGE:$TAG"
cd "$DIR"
git -c user.name=ci-bot -c user.email=ci-bot@forgejo.local \
commit -am "${{ inputs.app-name }}: deploy $TAG" || { echo "tag unchanged, nothing to deploy"; exit 0; }
git push