web-check/.github/workflows/docker.yml

74 lines
2.0 KiB
YAML
Raw Normal View History

name: 🐳 Build + Publish Docker Image
on:
workflow_dispatch:
push:
branches:
- master
tags:
- '*'
paths:
- src/**
- api/**
- public/**
- Dockerfile
env:
IMAGE_NAME: web-check
DOCKER_USER: lissy93
GHCR_REGISTRY: ghcr.io
DOCKERHUB_REGISTRY: docker.io
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
2024-05-24 05:21:47 +02:00
uses: actions/checkout@v4
- name: Extract tag name
shell: bash
run: echo "GIT_TAG=$(echo ${GITHUB_REF#refs/tags/} | sed 's/\//_/g')" >> $GITHUB_ENV
- name: Compute tags
id: compute-tags
run: |
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "GHCR_TAG=${GHCR_REGISTRY}/${DOCKER_USER}/${IMAGE_NAME}:latest" >> $GITHUB_ENV
echo "DOCKERHUB_TAG=${DOCKERHUB_REGISTRY}/${DOCKER_USER}/${IMAGE_NAME}:latest" >> $GITHUB_ENV
else
echo "GHCR_TAG=${GHCR_REGISTRY}/${DOCKER_USER}/${IMAGE_NAME}:${GIT_TAG}" >> $GITHUB_ENV
echo "DOCKERHUB_TAG=${DOCKERHUB_REGISTRY}/${DOCKER_USER}/${IMAGE_NAME}:${GIT_TAG}" >> $GITHUB_ENV
fi
- name: Set up QEMU
2024-05-24 05:21:47 +02:00
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
2024-05-24 05:21:47 +02:00
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
2024-05-24 05:21:47 +02:00
uses: docker/login-action@v3
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
2024-05-24 05:21:47 +02:00
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKERHUB_REGISTRY }}
username: ${{ env.DOCKER_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push Docker images
2024-05-24 05:21:47 +02:00
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
2024-02-29 17:03:50 +01:00
platforms: linux/amd64,linux/arm64/v8
tags: |
${{ env.GHCR_TAG }}
${{ env.DOCKERHUB_TAG }}