57 lines
2.1 KiB
YAML
57 lines
2.1 KiB
YAML
name: Build + push avatar image
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
REGISTRY: gitea.saas.vnc.biz
|
|
IMAGE: gitea.saas.vnc.biz/vnclagoon/vnctalk-avatar
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Compute image tag
|
|
run: |
|
|
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-7)
|
|
echo "SHORT_SHA=${SHORT_SHA}" >> $GITHUB_ENV
|
|
|
|
# kaniko: build + push without a Docker daemon (runner job container has
|
|
# no /var/run/docker.sock). All deps are public (npm/yarn), no NPM_TOKEN.
|
|
- name: Fetch kaniko (daemon-less image builder)
|
|
run: |
|
|
set -euo pipefail
|
|
curl -fsSL -o /tmp/crane.tgz \
|
|
https://github.com/google/go-containerregistry/releases/download/v0.21.9/go-containerregistry_Linux_x86_64.tar.gz
|
|
tar -xzf /tmp/crane.tgz -C /usr/local/bin crane
|
|
mkdir -p /tmp/kaniko-root
|
|
crane export gcr.io/kaniko-project/executor:debug /tmp/kaniko-fs.tar
|
|
tar -xf /tmp/kaniko-fs.tar -C /tmp/kaniko-root
|
|
cp /tmp/kaniko-root/kaniko/executor /usr/local/bin/kaniko-executor
|
|
chmod +x /usr/local/bin/kaniko-executor
|
|
/usr/local/bin/kaniko-executor version
|
|
|
|
- name: Configure registry auth for push
|
|
run: |
|
|
AUTH=$(printf '%s:%s' "${REGISTRY_USER}" "${REGISTRY_TOKEN}" | base64 -w0)
|
|
CFG=$(printf '{"auths":{"%s":{"auth":"%s"}}}' "${REGISTRY}" "${AUTH}")
|
|
mkdir -p /kaniko/.docker "$HOME/.docker"
|
|
printf '%s' "$CFG" > /kaniko/.docker/config.json
|
|
printf '%s' "$CFG" > "$HOME/.docker/config.json"
|
|
echo "DOCKER_CONFIG=/kaniko/.docker" >> "$GITHUB_ENV"
|
|
|
|
- name: Build + push avatar image
|
|
run: |
|
|
/usr/local/bin/kaniko-executor \
|
|
--context "dir://${GITHUB_WORKSPACE}" \
|
|
--dockerfile Dockerfile \
|
|
--skip-tls-verify-registry="${REGISTRY}" \
|
|
--destination "${IMAGE}:sha-${SHORT_SHA}" \
|
|
--destination "${IMAGE}:latest"
|