buildx 0.38.1 is baked into git.fristy.net/actions/runner-images. Creating a docker-container builder with the CLI keeps the registry cache (cache-from/cache-to) working without pulling the action.
64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
name: Deploy
|
|
|
|
on:
|
|
push:
|
|
branches: ["main"]
|
|
tags: ["v*"]
|
|
|
|
concurrency:
|
|
group: deploy-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
REGISTRY: git.fristy.net
|
|
IMAGE_NAME: fristy/fristydev
|
|
|
|
jobs:
|
|
image:
|
|
name: Build & Push Image
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Login to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
- name: Set up Buildx
|
|
# buildx ships with the runner image; only a builder instance is missing,
|
|
# and the docker-container driver is what the registry cache needs.
|
|
run: docker buildx create --name ci --driver docker-container --use
|
|
- name: Resolve tags
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=semver,pattern={{version}}
|
|
type=sha,prefix=
|
|
- name: Build & push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
|
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
deploy:
|
|
name: Trigger Deploy
|
|
needs: image
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Trigger Deploy
|
|
run: |
|
|
curl --fail -X POST "${{ secrets.WEBHOOK_URL }}"
|