Attempt to automate registry images
All checks were successful
CI / Lint & Format (push) Successful in 4s
CI / Tests (Pytest + Alembic + Postgres) (push) Successful in 9m25s
CI / Docker Build (push) Successful in 10m28s

This commit is contained in:
2025-09-30 13:27:35 +01:00
parent 48c5731a8a
commit e10b51c8e3

View File

@@ -11,6 +11,7 @@ permissions:
env:
PYTHON_VERSION: "3.11"
IMAGE_NAME: keywarden-api
# Used by tests / alembic; matches docker compose environment
KEYWARDEN_POSTGRES_USER: postgres
KEYWARDEN_POSTGRES_PASSWORD: postgres
@@ -144,7 +145,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
# Detect runner flavor and pick cache mode
# Choose Buildx cache backend: gha on GitHub, local on act_runner
- name: Select Buildx cache backend
run: |
if [ "${ACT:-}" = "true" ]; then
@@ -155,23 +156,36 @@ jobs:
echo "CACHE_FROM=type=gha" >> $GITHUB_ENV
fi
# (Only needed for local cache on act_runner)
- name: Prepare local Buildx cache dir
- name: Prepare local cache dir (act_runner only)
if: ${{ env.ACT == 'true' }}
run: mkdir -p /tmp/.buildx-cache
- name: Set image reference (Gitea)
run: |
echo "GT_IMAGE=${{ secrets.GITEA_REGISTRY }}/${{ secrets.GITEA_NAMESPACE }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
- name: Set up QEMU (optional)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
# optional: helps debugging cache issues
buildkitd-flags: --debug
- name: Build image (no push)
- name: Set image reference
run: echo "GT_IMAGE=${{ secrets.REGISTRY_HOST }}/${{ secrets.REGISTRY_NAMESPACE }}/${{ env.IMAGE_NAME }}" >> $GITHUB_ENV
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.REGISTRY_HOST }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build & push
uses: docker/build-push-action@v5
with:
context: .
tags: keywarden:ci
push: false # or true, if you want to push
load: false # set true if you need the image in the job afterward
cache-from: ${{ env.CACHE_FROM }}
cache-to: ${{ env.CACHE_TO }}
push: true
tags: |
${{ env.GT_IMAGE }}:${{ github.ref_name }}
${{ env.GT_IMAGE }}:sha-${{ github.sha }}
${{ env.GT_IMAGE }}:latest