Registry cache export was failing with 500 errors from the container registry. Inline cache embeds metadata in the image itself, avoiding the separate cache manifest upload.
61 lines
1.8 KiB
YAML
61 lines
1.8 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
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
${{ steps.meta.outputs.tag }}
|
|
${{ steps.meta.outputs.latest_tag }}
|
|
cache-from: type=registry,ref=${{ steps.meta.outputs.latest_tag }}
|
|
cache-to: type=inline
|
|
|
|
- name: Update deployment image tag
|
|
run: |
|
|
sed -i "s|image: git\.mcintire\.me/graham/aprs\.me:.*|image: ${{ steps.meta.outputs.tag }}|g" k8s/deployment.yaml
|
|
git config user.email "ci@git.mcintire.me"
|
|
git config user.name "CI"
|
|
git add k8s/deployment.yaml
|
|
git diff --cached --quiet || git commit -m "chore: update aprs.me image to ${{ steps.meta.outputs.tag }} [skip ci]"
|
|
git push origin HEAD:main
|