Build and Push Docker Image #18
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 Push Docker Image | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
workflow_dispatch: | |
inputs: | |
reason: | |
description: "Write why you are requesting a manual release" | |
type: string | |
required: true | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
PROVIDER: ghcr.io | |
REPO_NAME: ${{ github.repository }} | |
IMAGE_NAME: ghcr.io/${{ github.repository }} | |
PLATFORMS: linux/amd64,linux/arm64 | |
jobs: | |
build-and-push: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-24.04 | |
# See https://github.com/actions/runner/issues/859#issue-766582646 | |
if: > | |
(github.repository == 'basementdevs/scylla-studio') && | |
((github.event_name == 'push' && contains(github.event.head_commit.message, '[CD]')) || (github.event_name == 'workflow_dispatch')) | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 | |
with: | |
platforms: ${{ env.PLATFORMS }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 | |
with: | |
platforms: ${{ env.PLATFORMS }} | |
- name: Log in to GitHub Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # 3.3.0 | |
with: | |
registry: ${{ env.PROVIDER }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Docker image | |
run: | | |
docker buildx build \ | |
--platform "${{ env.PLATFORMS }}" \ | |
--label "org.opencontainers.image.source=https://github.com/${{ env.REPO_NAME }}" \ | |
--label "org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ | |
--tag "${{ env.IMAGE_NAME }}:latest" \ | |
--tag "${{ env.IMAGE_NAME }}:${{ github.sha }}" \ | |
--tag "${{ env.IMAGE_NAME }}:${{ github.ref_name }}" \ | |
--push \ | |
--progress=plain \ | |
--file .docker/Dockerfile \ | |
. |