mirror of
https://github.com/DumbWareio/DumbDrop.git
synced 2025-10-22 23:31:57 +00:00
68 lines
2.3 KiB
YAML
68 lines
2.3 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # Trigger the workflow on pushes to the main branch
|
|
- dev # Trigger the workflow on pushes to the dev 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=dumbwareio/dumbdrop
|
|
tags: |
|
|
# Add :dev tag for pushes to the dev branch
|
|
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
|
|
# 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
|