2026-07-03 22:32:55 +00:00
|
|
|
name: Image Build Probe
|
|
|
|
|
|
|
|
|
|
on:
|
2026-07-03 22:45:18 +00:00
|
|
|
push:
|
|
|
|
|
paths:
|
|
|
|
|
- ".forgejo/workflows/image-build.yaml"
|
|
|
|
|
- "Dockerfile"
|
2026-07-03 22:32:55 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
|
|
env:
|
|
|
|
|
REGISTRY: forgejo.coulomb.social
|
|
|
|
|
IMAGE_NAME: coulomb/forgejo-actions-probe
|
2026-07-03 22:36:50 +00:00
|
|
|
DOCKER_HOST: tcp://127.0.0.1:2375
|
2026-07-03 22:32:55 +00:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
image-build:
|
|
|
|
|
runs-on: container-build
|
|
|
|
|
steps:
|
2026-07-03 22:45:18 +00:00
|
|
|
- name: Build and push image
|
2026-07-03 22:41:51 +00:00
|
|
|
env:
|
|
|
|
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
|
|
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
2026-07-03 22:36:50 +00:00
|
|
|
run: |
|
2026-07-03 22:45:18 +00:00
|
|
|
set -eu
|
|
|
|
|
apk add --no-cache git 2>/dev/null || true
|
|
|
|
|
if ! command -v git >/dev/null 2>&1; then
|
|
|
|
|
echo "git unavailable; using inline build context"
|
|
|
|
|
mkdir -p buildctx
|
|
|
|
|
echo forgejo-image-build-probe-ok > buildctx/probe.txt
|
|
|
|
|
printf 'FROM alpine:3.20\nCOPY probe.txt /\n' > buildctx/Dockerfile
|
|
|
|
|
else
|
|
|
|
|
git clone --depth 1 "https://forgejo.coulomb.social/${GITHUB_REPOSITORY}.git" buildctx
|
|
|
|
|
cd buildctx
|
|
|
|
|
fi
|
|
|
|
|
mkdir -p "${HOME}/bin"
|
2026-07-03 22:39:53 +00:00
|
|
|
wget -qO- https://download.docker.com/linux/static/stable/x86_64/docker-27.3.1.tgz | tar xz --strip-components=1 -C "${HOME}/bin" docker/docker
|
2026-07-03 22:41:51 +00:00
|
|
|
export PATH="${HOME}/bin:${PATH}"
|
|
|
|
|
docker version
|
|
|
|
|
echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" -u "${REGISTRY_USER}" --password-stdin
|
2026-07-03 22:45:18 +00:00
|
|
|
TAG="${GITHUB_SHA:-manual}"
|
|
|
|
|
SHORT="${TAG:0:7}"
|
2026-07-03 22:32:55 +00:00
|
|
|
IMAGE="${REGISTRY}/${IMAGE_NAME}"
|
2026-07-03 22:45:18 +00:00
|
|
|
CTX="${PWD}"
|
|
|
|
|
if [ -d buildctx ]; then CTX="${PWD}/buildctx"; fi
|
|
|
|
|
docker build -t "${IMAGE}:latest" -t "${IMAGE}:${SHORT}" "${CTX}"
|
|
|
|
|
docker push "${IMAGE}:latest"
|
|
|
|
|
docker push "${IMAGE}:${SHORT}"
|
|
|
|
|
echo "pushed ${IMAGE}:latest and ${IMAGE}:${SHORT}"
|