Some checks failed
Build and deploy / Build container and manifests (push) Failing after 1m50s
114 lines
3.5 KiB
YAML
114 lines
3.5 KiB
YAML
name: Build and deploy
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- feature/**
|
|
tags:
|
|
- v*.*.*
|
|
|
|
env:
|
|
OCI_REPO: git.huizinga.dev/dreaded_x/${{ gitea.event.repository.name}}
|
|
|
|
jobs:
|
|
build:
|
|
name: Build container and manifests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Get Git commit timestamps
|
|
run: echo "TIMESTAMP=$(git log -1 --pretty=%ct)" >> $GITHUB_ENV
|
|
|
|
- name: Login to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: git.huizinga.dev
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Cache Docker layers
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ runner.temp }}/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-
|
|
|
|
- name: Install kustomize
|
|
run: |
|
|
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
|
|
|
|
- name: Setup Flux CLI
|
|
uses: https://github.com/fluxcd/flux2/action@main
|
|
with:
|
|
version: v2.5.0
|
|
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.OCI_REPO }}
|
|
tags: |
|
|
type=edge
|
|
type=ref,event=branch
|
|
type=semver,pattern=v{{version}}
|
|
type=semver,pattern=v{{major}}.{{minor}}
|
|
type=semver,pattern=v{{major}}
|
|
cache-from: type=local,src=${{ runner.temp }}/.buildx-cache
|
|
cache-to: type=local,dest=${{ runner.temp }}/.buildx-cache-new,mode=max
|
|
|
|
- # Temp fix
|
|
# https://github.com/docker/build-push-action/issues/252
|
|
# https://github.com/moby/buildkit/issues/1896
|
|
name: Move cache
|
|
run: |
|
|
rm -rf ${{ runner.temp }}/.buildx-cache
|
|
mv ${{ runner.temp }}/.buildx-cache-new ${{ runner.temp }}/.buildx-cache
|
|
|
|
- name: Build and export to docker
|
|
id: build
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
load: true
|
|
annotations: ${{ steps.meta.outputs.annotations }}
|
|
env:
|
|
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
|
|
|
- name: Generate CRDs
|
|
run: |
|
|
docker run --rm ${{ steps.build.outputs.imageid }} /crdgen > ./manifests/crds.yaml
|
|
|
|
- name: Push container
|
|
uses: docker/build-push-action@v6
|
|
id: push
|
|
with:
|
|
context: .
|
|
push: true
|
|
sbom: true
|
|
provenance: mode=max
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
annotations: ${{ steps.meta.outputs.annotations }}
|
|
env:
|
|
SOURCE_DATE_EPOCH: ${{ env.TIMESTAMP }}
|
|
|
|
- name: Kustomize manifests
|
|
run: |
|
|
./kustomize build ./manifests | sed "s/\${DIGEST}/${{ steps.push.outputs.digest }}/" > ./manifests.yaml
|
|
|
|
- name: Push manifests
|
|
run: |
|
|
flux push artifact oci://$OCI_REPO/manifests:latest \
|
|
--path="./manifests.yaml" \
|
|
--source="$(git config --get remote.origin.url)" \
|
|
--revision="$(git rev-parse HEAD)" \
|
|
$(echo "${{ steps.meta.outputs.labels }}" | sed -e 's/^/-a /')
|
|
|
|
flux tag artifact oci://$OCI_REPO/manifests:latest \
|
|
$(echo "${{ steps.meta.outputs.tags }}" | sed -e 's/^.*:/--tag /')
|