Skip to content

Build and Push Docker Image #24

Build and Push Docker Image

Build and Push Docker Image #24

Workflow file for this run

name: Build and Push Docker Image
on:
workflow_dispatch:
inputs:
ref:
description: 'Git reference to checkout (branch or SHA)'
required: false
default: 'latest'
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Docker Setup QEMU
uses: docker/setup-qemu-action@v1
- name: Docker Setup Buildx
uses: docker/setup-buildx-action@v1
- name: Docker Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set ref name
run: |
REF_NAME=$(echo $GITHUB_REF | sed 's|refs/tags/||')
echo "REF_NAME=$REF_NAME" >> $GITHUB_ENV
- name: Set Docker repository names
run: |
echo "repo_all=$(echo "${{ github.repository }}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
echo "repo_name=$(echo "${{ github.event.repository.name }}" | awk '{print tolower($0)}')" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: |
vinlic/${{ env.repo_name }}:${{ env.REF_NAME }}
vinlic/${{ env.repo_name }}:latest
ghcr.io/${{ env.repo_all }}:${{ env.REF_NAME }}
ghcr.io/${{ env.repo_all }}:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max