Skip to content

Removed version

Removed version #6

name: Build and Push Docker Images
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
env:
REGISTRY: ghcr.io
BACKEND_IMAGE_NAME: ${{ github.repository }}-backend
FRONTEND_IMAGE_NAME: ${{ github.repository }}-frontend
jobs:
build-and-push-backend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate certificate and password
run: |
chmod +x ./docker/generate-credentials.sh
./docker/generate-credentials.sh ${{ secrets.FRONTEND_BASIC_AUTH_USERNAME }} ${{ secrets.FRONTEND_BASIC_AUTH_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Backend Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./backend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-and-push-frontend:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate certificate and password
run: |
chmod +x ./docker/generate-cert.sh
./docker/generate-cert.sh
chmod +x ./docker/setup-perms.sh
./docker/setup-perms.sh
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=sha,prefix={{branch}}-
type=raw,value=latest,enable={{is_default_branch}}
- name: Build and push Frontend Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./frontend/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VITE_API_ROOT=${{ secrets.FRONTEND_API_ROOT }}