Build and Push Docker image to Docker Hub #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Builds a docker image. | |
# Tag pattern | |
# 'main' - latest | |
name: Build and push Docker images (push/pull request) | |
on: | |
workflow_dispatch: | |
# release: | |
# types: [published] | |
# push: | |
# branches: | |
# - main | |
env: | |
DOCKER_PLATFORMS: linux/386 | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set DACQUERY_BRANCH env. | |
run: echo "DACQUERY_BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
- name: Is branch "main"? | |
if: ${{ env.DACQUERY_BRANCH == 'main' }} | |
run: | | |
echo "IMAGE_TAG_BASE=latest" >> $GITHUB_ENV | |
- name: Is branch "experimental"? | |
if: ${{ env.DACQUERY_BRANCH == 'experimental' }} | |
run: | | |
echo "IMAGE_TAG_BASE=experimental" >> $GITHUB_ENV | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Login to Docker Registry | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PERSONAL_ACCESS_TOKEN }} | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
context: ./ | |
file: ./Dockerfile | |
platforms: ${{ env.DOCKER_PLATFORMS }} | |
push: ${{ env.IMAGE_TAG_BASE != '' }} | |
tags: ${{ 'mikebrady/dacquery' }}:${{ env.IMAGE_TAG_BASE }} | |
build-args: | | |
DACQUERY_BRANCH=${{ env.DACQUERY_BRANCH }} |