80 lines
2.2 KiB
YAML
80 lines
2.2 KiB
YAML
name: Docker Build
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, docker ]
|
|
|
|
jobs:
|
|
docker-backend:
|
|
name: Build and Push Backend Image
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Forgejo Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ forgejo.server_url }}
|
|
username: ${{ forgejo.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ forgejo.server_url }}/${{ forgejo.repository }}/backend
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=sha,prefix={{branch}}-
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./backend
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
docker-frontend:
|
|
name: Build and Push Frontend Image
|
|
runs-on: docker
|
|
steps:
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Forgejo Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ forgejo.server_url }}
|
|
username: ${{ forgejo.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ forgejo.server_url }}/${{ forgejo.repository }}/frontend
|
|
tags: |
|
|
type=ref,event=branch
|
|
type=sha,prefix={{branch}}-
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
|
|
- name: Build and push image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./frontend
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|