Merge pull request #21 from greirson/even-dumber-drop #35
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 # Trigger the workflow on pushes to the main branch | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the repository | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Step 2: Log in to Docker Hub | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Step 3: Setup QEMU to enable multiarch builds | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
# Step 4: Set up docker buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Step 5: Extract metadata and set versions | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# image name is dumbdrop, in the docker user's repo | |
# this allows the push to work in forks | |
images: | | |
name=${{ secrets.DOCKER_USERNAME }}/dumbdrop | |
tags: | | |
# the semantic versioning tags add "latest" when a version tag is present | |
# but since version tags aren't being used (yet?) let's add "latest" anyway | |
type=raw,value=latest | |
# output x.y.z, based on a tag vx.y.z (e.g. 1.1.2 for a tag v1.1.2) | |
type=semver,pattern={{version}} | |
# output x.y, based on a tag vx.y.z | |
type=semver,pattern={{major}}.{{minor}} | |
# output x, based on a tag vx.y.z, disabled if x is zero | |
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
# full length sha | |
type=sha,format=long | |
# Step 6: build and push the image for multiple archs | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# build and push for amd64 and arm64 platforms | |
platforms: linux/amd64,linux/arm64 |