Skip to content

Commit

Permalink
Adds workflow to build and publish Docker img
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 authored Jul 22, 2023
1 parent 9f04d06 commit 1d2de60
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
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
uses: actions/checkout@v2

- 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
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ${{ env.GHCR_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to DockerHub
uses: docker/login-action@v1
with:
registry: ${{ env.DOCKERHUB_REGISTRY }}
username: ${{ env.DOCKER_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
tags: |
${{ env.GHCR_TAG }}
${{ env.DOCKERHUB_TAG }}

0 comments on commit 1d2de60

Please sign in to comment.