Some checks failed
Build and Push Docker Images / build-and-push (push) Failing after 1m6s
Switching the runner to Docker improves consistency and aligns with containerized build environments. This change ensures better compatibility and reduces discrepancies in builds.
73 lines
2.5 KiB
YAML
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: docker
|
|
|
|
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 }}" |