Skip to content
# Reference: https://github.com/docker/build-push-action
name: Docker Build and Publish
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
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: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine Docker Image Tag
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/master" ]]; then
echo "tag=latest" >> $GITHUB_ENV
else
BRANCH_NAME="${{ github.head_ref || github.ref_name }}"
echo "tag=${BRANCH_NAME}" >> $GITHUB_ENV
fi
- name: Output Docker Image Tag
run: echo "Docker image tag is ${{ env.tag }}"
- name: Build and push docker image
uses: docker/build-push-action@v3
with:
push: true
tags: ghcr.io/${{ github.repository }}/voluseg:${{ env.tag }}
context: .
file: Dockerfile