Switch deployment pipeline from GitLab Agent kubectl to FluxCD image automation. CI now only builds and pushes tagged images to Forgejo registry; FluxCD detects new tags and updates the deployment manifest. Fix Ecto.MultipleResultsError on /dashboard when a device has multiple Preseem access point records by using limit(1) instead of Repo.get_by.
54 lines
1.5 KiB
YAML
54 lines
1.5 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
DOCKER_BUILDKIT: 1
|
|
DOCKER_TLS_CERTDIR: ""
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ secrets.REGISTRY_URL }}
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
run: |
|
|
TIMESTAMP=$(date +%s)
|
|
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
|
|
IMAGE=${{ secrets.REGISTRY_URL }}/${{ github.repository }}
|
|
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
|
|
echo "tag=${IMAGE}:main-${TIMESTAMP}-${SHORT_SHA}" >> $GITHUB_OUTPUT
|
|
echo "latest_tag=${IMAGE}:latest" >> $GITHUB_OUTPUT
|
|
echo "cache_tag=${IMAGE}:buildcache" >> $GITHUB_OUTPUT
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: k8s/Dockerfile
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.tag }}
|
|
${{ steps.meta.outputs.latest_tag }}
|
|
cache-from: type=registry,ref=${{ steps.meta.outputs.cache_tag }}
|
|
cache-to: type=registry,ref=${{ steps.meta.outputs.cache_tag }},mode=max
|