Files
schafkop-neu/.github/workflows/BuildAndPushContainer.yml

66 lines
1.8 KiB
YAML

name: Build and Push Docker Image
on:
workflow_dispatch:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/app
jobs:
build-and-push:
runs-on: [self-hosted]
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels)
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=short
type=ref,event=branch
- name: Build and push Docker image (multi-arch)
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
NODE_VERSION=20-bookworm-slim
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Notify updater (GET, bearer)
if: ${{ success() && github.ref == 'refs/heads/main' }}
env:
WEBHOOK_TOKEN: ${{ secrets.WEBHOOK_TOKEN }}
run: |
curl -fsS --retry 5 -H "Authorization: Bearer ${WEBHOOK_TOKEN}" http://10.0.3.185:8080/v1/update