Files
eventspace/.gitea/workflows/docker-build.yml
Felipe Cardoso 58c360285f
All checks were successful
Build and Push Docker Images / build-and-push (push) Successful in 1m53s
Set up container image for Docker-based CI workflow
Added a container image definition to use ghcr.io/catthehacker/ubuntu:act-latest in the build-and-push job. This enhances compatibility when running the workflow locally with act and ensures consistency in the execution environment. Corrected spacing in the secrets configuration for better code formatting.
2025-02-27 17:23:24 +01:00

74 lines
2.6 KiB
YAML

name: Build and Push Docker Images
on:
push:
branches: [ main ]
tags: [ 'v*' ]
workflow_dispatch:
jobs:
build-and-push:
runs-on: docker
container:
image: ghcr.io/catthehacker/ubuntu:act-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 }}"