Build and upload Docker Image #36
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
name: Build and upload Docker Image | |
on: | |
pull_request: | |
branches: ["releases/**"] | |
types: [labeled, opened, synchronize, reopened] | |
workflow_run: | |
workflows: [Build Wheels and upload to PyPI] | |
types: [completed] | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
permissions: | |
contents: read # to fetch code (actions/checkout) | |
jobs: | |
docker_build: | |
name: Build the Docker Image | |
# Build docker image on one of two conditions: | |
# 1. `pypi_publish` workflow runs to completion and succeeds, and the job was triggered by a new release. | |
# 2. A dev manually dispatched the Build workflow for testing in a releases/X.Y.Z pull request. | |
if: | | |
( | |
${{ github.event.workflow_run.conclusion == 'success'}} | |
&& | |
${{ github.event_name == 'release' && github.event.action == 'published' }} | |
) | |
|| | |
( | |
${{ github.event_name == 'workflow_dispatch' }} | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout ${{ github.repository }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Checkout the latest release branch | |
ref: ${{ github.event.workflow_run.head_sha }} | |
- name: Set up QEMU (For Linux Arm Containers) | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
# Uses the latest version of Buildx and Buildkit | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
buildkitd-flags: --debug | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker Metadata Information | |
uses: docker/metadata-action@v5 | |
id: docker_metadata | |
with: | |
github-token: ${{ github.token }} | |
images: | | |
${{ secrets.DOCKERHUB_USERNAME }}/ark-analysis | |
flavor: | | |
latest=auto | |
tags: | | |
type=ref,event=branch,pattern={{raw}} | |
type=ref,event=pr,pattern={{raw}} | |
type=semver,pattern={{raw}} | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.docker_metadata.outputs.tags }} | |
labels: ${{ steps.docker_metadata.outputs.labels }} | |
cache-to: type=gha,mode=max | |
cache-from: type=gha |