Skip to content

Build and Release Web version web #50

Build and Release Web version web

Build and Release Web version web #50

run-name: "Build and Release Web version ${{ github.ref_name }}"
on:
push:
branches:
- web
paths:
- .github/workflows/build-release.yaml
- backend/**/*
- frontend/**/*
workflow_dispatch:
env:
IMAGE_PREFIX: ghcr.io/dk10ws/slcm
jobs:
build-backend:
name: Build FastAPI application docker image
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
ref: "web"
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push backend Docker Image
uses: docker/build-push-action@v6
with:
context: backend
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.IMAGE_PREFIX }}-backend:latest
${{ env.IMAGE_PREFIX }}-backend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-frontend:
name: Build Flutter Web application docker image
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6
with:
ref: "web"
- name: Cache pub deps
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }}
restore-keys: ${{ runner.os }}-pub-
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
- name: Build web app
working-directory: frontend
run: |
flutter pub get
flutter build web
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push frontend Docker Image
uses: docker/build-push-action@v6
with:
context: frontend
file: frontend/Dockerfile.actions
push: true
platforms: linux/amd64,linux/arm64
tags: |
${{ env.IMAGE_PREFIX }}-frontend:latest
${{ env.IMAGE_PREFIX }}-frontend:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
update-manifests:
runs-on: ubuntu-slim
needs:
- build-backend
- build-frontend
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Update image tags
run: |
yq -i ".spec.template.spec.containers[0].image = \"${{ env.IMAGE_PREFIX }}-frontend:${GITHUB_SHA}\"" k8s/frontend/deployment.yaml
yq -i ".spec.template.spec.containers[0].image = \"${{ env.IMAGE_PREFIX }}-backend:${GITHUB_SHA}\"" k8s/backend/deployment.yaml
- name: Commit to repo
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
commit_message: "k8s: Bump images to ${{ github.sha }} [no ci]"
file_pattern: "k8s/**/deployment.yaml"