refactor: update build workflow to use dynamic registry and improve login steps
Some checks failed
Build and Deploy / build-web (push) Failing after 23s
Build and Deploy / build-api (push) Failing after 22s

This commit is contained in:
d.viti
2025-10-03 01:32:12 +02:00
parent 62135bbd12
commit 99447b874b

View File

@@ -1,7 +1,10 @@
name: Build and Push Docker Images name: Build and Deploy
on: on:
push: push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
@@ -14,18 +17,19 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Gitea Container Registry - name: Log in to Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: git.commandware.com registry: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}
username: ${{ gitea.actor }} username: ${{ secrets.USERNAME }}
password: ${{ secrets.PACKAGES_PUSH_TOKEN }} password: ${{ secrets.PACKAGES_PUSH_TOKEN }}
- name: Extract metadata for web image - name: Extract metadata for web image
id: meta-web id: meta-web
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: git.commandware.com/demos/api7-demo/web images: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web
tags: | tags: |
type=ref,event=branch type=ref,event=branch
@@ -34,11 +38,11 @@ jobs:
with: with:
context: ./web context: ./web
file: ./web/Dockerfile file: ./web/Dockerfile
push: true push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta-web.outputs.tags }} tags: ${{ steps.meta-web.outputs.tags }}
labels: ${{ steps.meta-web.outputs.labels }} labels: ${{ steps.meta-web.outputs.labels }}
cache-from: type=registry,ref=git.commandware.com/demos/api7-demo/web:buildcache cache-from: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web:buildcache
cache-to: type=registry,ref=git.commandware.com/demos/api7-demo/web:buildcache,mode=max cache-to: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web:buildcache,mode=max
build-api: build-api:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -49,18 +53,19 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to Gitea Container Registry - name: Log in to Container Registry
if: github.event_name == 'push'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: git.commandware.com registry: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}
username: ${{ gitea.actor }} username: ${{ secrets.USERNAME }}
password: ${{ secrets.PACKAGES_PUSH_TOKEN }} password: ${{ secrets.PACKAGES_PUSH_TOKEN }}
- name: Extract metadata for api image - name: Extract metadata for api image
id: meta-api id: meta-api
uses: docker/metadata-action@v5 uses: docker/metadata-action@v5
with: with:
images: git.commandware.com/demos/api7-demo/api images: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api
tags: | tags: |
type=ref,event=branch type=ref,event=branch
@@ -69,8 +74,8 @@ jobs:
with: with:
context: ./api context: ./api
file: ./api/Dockerfile file: ./api/Dockerfile
push: true push: ${{ github.event_name == 'push' }}
tags: ${{ steps.meta-api.outputs.tags }} tags: ${{ steps.meta-api.outputs.tags }}
labels: ${{ steps.meta-api.outputs.labels }} labels: ${{ steps.meta-api.outputs.labels }}
cache-from: type=registry,ref=git.commandware.com/demos/api7-demo/api:buildcache cache-from: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api:buildcache
cache-to: type=registry,ref=git.commandware.com/demos/api7-demo/api:buildcache,mode=max cache-to: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api:buildcache,mode=max