76 lines
2.2 KiB
YAML
76 lines
2.2 KiB
YAML
name: Build and push Docker image
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/check-printing
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
|
|
jobs:
|
|
build-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Log in to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ vars.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Extract image metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=raw,value=latest,enable={{is_default_branch}}
|
|
type=ref,event=branch
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=sha,prefix=sha-
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: docker/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
- name: Notify success
|
|
if: success()
|
|
run: |
|
|
curl -s -X POST "${{ secrets.NTFY_URL }}" \
|
|
-H "Authorization: Bearer ${{ secrets.NTFY_TOKEN }}" \
|
|
-H "Title: check-printing built ✓" \
|
|
-H "Priority: default" \
|
|
-H "Tags: white_check_mark" \
|
|
-d "Image pushed: ${{ env.IMAGE_NAME }}@${{ github.sha }}"
|
|
|
|
- name: Notify failure
|
|
if: failure()
|
|
run: |
|
|
curl -s -X POST "${{ secrets.NTFY_URL }}" \
|
|
-H "Authorization: Bearer ${{ secrets.NTFY_TOKEN }}" \
|
|
-H "Title: check-printing build failed ✗" \
|
|
-H "Priority: high" \
|
|
-H "Tags: x" \
|
|
-d "Build failed on ${{ github.ref_name }} — ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|