Attempt to automate registry images
This commit is contained in:
40
.github/workflows/ci.yml
vendored
40
.github/workflows/ci.yml
vendored
@@ -11,6 +11,7 @@ permissions:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHON_VERSION: "3.11"
|
PYTHON_VERSION: "3.11"
|
||||||
|
IMAGE_NAME: keywarden-api
|
||||||
# Used by tests / alembic; matches docker compose environment
|
# Used by tests / alembic; matches docker compose environment
|
||||||
KEYWARDEN_POSTGRES_USER: postgres
|
KEYWARDEN_POSTGRES_USER: postgres
|
||||||
KEYWARDEN_POSTGRES_PASSWORD: postgres
|
KEYWARDEN_POSTGRES_PASSWORD: postgres
|
||||||
@@ -144,7 +145,7 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
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
|
- name: Select Buildx cache backend
|
||||||
run: |
|
run: |
|
||||||
if [ "${ACT:-}" = "true" ]; then
|
if [ "${ACT:-}" = "true" ]; then
|
||||||
@@ -155,23 +156,36 @@ jobs:
|
|||||||
echo "CACHE_FROM=type=gha" >> $GITHUB_ENV
|
echo "CACHE_FROM=type=gha" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# (Only needed for local cache on act_runner)
|
- name: Prepare local cache dir (act_runner only)
|
||||||
- name: Prepare local Buildx cache dir
|
|
||||||
if: ${{ env.ACT == 'true' }}
|
if: ${{ env.ACT == 'true' }}
|
||||||
run: mkdir -p /tmp/.buildx-cache
|
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
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
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
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
tags: keywarden:ci
|
push: true
|
||||||
push: false # or true, if you want to push
|
tags: |
|
||||||
load: false # set true if you need the image in the job afterward
|
${{ env.GT_IMAGE }}:${{ github.ref_name }}
|
||||||
cache-from: ${{ env.CACHE_FROM }}
|
${{ env.GT_IMAGE }}:sha-${{ github.sha }}
|
||||||
cache-to: ${{ env.CACHE_TO }}
|
${{ env.GT_IMAGE }}:latest
|
||||||
Reference in New Issue
Block a user