82 lines
2.7 KiB
YAML
82 lines
2.7 KiB
YAML
name: Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-web:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Container Registry
|
|
if: github.event_name == 'push'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}
|
|
username: ${{ secrets.USERNAME }}
|
|
password: ${{ secrets.PACKAGES_PUSH_TOKEN }}
|
|
|
|
- name: Extract metadata for web image
|
|
id: meta-web
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web
|
|
tags: |
|
|
type=ref,event=branch
|
|
|
|
- name: Build and push web image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./web
|
|
file: ./web/Dockerfile
|
|
push: ${{ github.event_name == 'push' }}
|
|
tags: ${{ steps.meta-web.outputs.tags }}
|
|
labels: ${{ steps.meta-web.outputs.labels }}
|
|
cache-from: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web:buildcache
|
|
cache-to: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/web:buildcache,mode=max
|
|
|
|
build-api:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Container Registry
|
|
if: github.event_name == 'push'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}
|
|
username: ${{ secrets.USERNAME }}
|
|
password: ${{ secrets.PACKAGES_PUSH_TOKEN }}
|
|
|
|
- name: Extract metadata for api image
|
|
id: meta-api
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api
|
|
tags: |
|
|
type=ref,event=branch
|
|
|
|
- name: Build and push api image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./api
|
|
file: ./api/Dockerfile
|
|
push: ${{ github.event_name == 'push' }}
|
|
tags: ${{ steps.meta-api.outputs.tags }}
|
|
labels: ${{ steps.meta-api.outputs.labels }}
|
|
cache-from: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api:buildcache
|
|
cache-to: type=registry,ref=${{ vars.DOCKER_REGISTRY || gitea.server_url }}/${{ gitea.repository }}/api:buildcache,mode=max
|