Use shared runner image build action
All checks were successful
Build runner image / build (push) Successful in 6m48s
Test blackout notifier / test (push) Successful in 3s
Hourly blackout check / check (push) Successful in 4s

This commit is contained in:
Meghdad
2026-07-17 23:03:40 +03:30
parent b8d27a3298
commit 0abf377f53
5 changed files with 37 additions and 94 deletions

View File

@@ -5,7 +5,8 @@ on:
branches:
- main
paths:
- runner-image/**
- requirements.lock
- .dockerignore
- .gitea/workflows/build-runner-image.yml
workflow_dispatch:
@@ -13,7 +14,7 @@ jobs:
build:
runs-on: ubuntu-latest
container:
image: mahgit.ir/meghdadfadaee/daily-blackout-check-base:node-20-bookworm
image: mahgit.ir/meghdadfadaee/build-runner-image-base:node-20-bookworm
credentials:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
@@ -21,54 +22,15 @@ jobs:
- name: Check out repository
uses: https://gitea.com/actions/checkout@v4
- name: Install Docker client
run: |
set -eu
for attempt in 1 2 3; do
if apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
--no-install-recommends docker.io; then
break
fi
if [ "$attempt" -eq 3 ]; then
echo "Unable to install the Docker client after 3 attempts"
exit 1
fi
sleep "$((attempt * 5))"
done
rm -rf /var/lib/apt/lists/*
docker version --format 'Docker client {{.Client.Version}}, server {{.Server.Version}}'
- name: Build, verify, and publish image
env:
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
set -eu
registry="mahgit.ir"
image="$registry/meghdadfadaee/daily-blackout-check-runner"
revision="$(git rev-parse --short=12 HEAD)"
candidate="$image:$revision"
cleanup() {
docker logout "$registry" >/dev/null 2>&1 || true
}
trap cleanup EXIT
printf '%s' "$REGISTRY_TOKEN" | docker login "$registry" \
--username "$REGISTRY_USERNAME" \
--password-stdin
docker build \
--pull \
--label "org.opencontainers.image.revision=$revision" \
--label "org.opencontainers.image.source=https://mahgit.ir/MeghdadFadaee/daily-blackout-check" \
--tag "$candidate" \
runner-image
docker run --rm "$candidate" python -c "import dotenv, jdatetime, requests"
docker run --rm "$candidate" pytest --version
docker run --rm "$candidate" ruff --version
docker push "$candidate"
docker tag "$candidate" "$image:latest"
docker push "$image:latest"
uses: https://mahgit.ir/MeghdadFadaee/build-runner-image-action@v1
with:
registry: mahgit.ir
image: mahgit.ir/meghdadfadaee/daily-blackout-check-runner
source-url: https://mahgit.ir/MeghdadFadaee/daily-blackout-check
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-token: ${{ secrets.REGISTRY_TOKEN }}
verify-commands: |
docker run --rm "$IMAGE_REF" python -c "import dotenv, jdatetime, requests"
docker run --rm "$IMAGE_REF" pytest --version
docker run --rm "$IMAGE_REF" ruff --version