Use shared runner image build action
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user