Files
eventspace/.gitea/workflows/docker-build.yml
Felipe Cardoso 407e93a8c7
Some checks failed
Build and Push Docker Images / build-and-push (push) Has been cancelled
Add CI workflow for Docker image build and push
This workflow automates building and pushing Docker images for the backend and frontend to the Gitea registry. It triggers on `main` branch pushes, tag pushes, or manual dispatch and supports version tagging based on Git references.
2025-02-27 16:12:02 +01:00

73 lines
2.5 KiB
YAML

name: Build and Push Docker Images
on:
push:
branches: [ main ]
tags: [ 'v*' ]
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: gitea.pragmazest.com
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
password: ${{ secrets.DOCKER_REGISTRY_ACCESS_TOKEN }}
- name: Extract metadata
id: meta
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION=latest
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
# Build and push backend image
- name: Build and push backend
uses: docker/build-push-action@v5
with:
context: ./backend
file: ./backend/Dockerfile
push: true
target: production
tags: |
gitea.pragmazest.com/${{ github.repository }}/backend:${{ steps.meta.outputs.version }}
gitea.pragmazest.com/${{ github.repository }}/backend:latest
labels: |
org.opencontainers.image.created=${{ steps.meta.outputs.date }}
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
# Build and push frontend image
- name: Build and push frontend
uses: docker/build-push-action@v5
with:
context: ./frontend
file: ./frontend/Dockerfile
push: true
target: runner
tags: |
gitea.pragmazest.com/${{ github.repository }}/frontend:${{ steps.meta.outputs.version }}
gitea.pragmazest.com/${{ github.repository }}/frontend:latest
labels: |
org.opencontainers.image.created=${{ steps.meta.outputs.date }}
org.opencontainers.image.version=${{ steps.meta.outputs.version }}
org.opencontainers.image.revision=${{ github.sha }}
- name: Image digests
run: |
echo "Backend image: gitea.pragmazest.com/${{ github.repository }}/backend:${{ steps.meta.outputs.version }}"
echo "Frontend image: gitea.pragmazest.com/${{ github.repository }}/frontend:${{ steps.meta.outputs.version }}"