-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5033247
commit e3c2497
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Docker Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
platforms: | ||
type: choice | ||
description: "Build Platforms" | ||
required: true | ||
default: "linux/amd64" | ||
options: | ||
- "linux/amd64" | ||
- "linux/amd64,linux/arm64" | ||
docker_tags: | ||
type: string | ||
description: "Docker Tags" | ||
required: true | ||
default: "dev" | ||
|
||
push: | ||
branches: | ||
- master | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build_and_push_docker: | ||
runs-on: ubuntu-latest | ||
env: | ||
dev_arch: "linux/amd64" | ||
release_arch: "linux/amd64,linux/arm64" | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
ghcr.io/${{ github.repository }} | ||
# All non-release actions will be tagged as `dev` (ie: push, workflow_dispatch) | ||
tags: | | ||
type=ref,event=tag | ||
type=raw,value=dev,enable=${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }} | ||
type=raw,value=${{ inputs.docker_tags }},enable=${{ github.event_name == 'workflow_dispatch' }} | ||
flavor: | | ||
latest=auto | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build and Push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
# If the event is a release, use the release_arch, otherwise use the | ||
# platforms input if present, falling back to dev_arch | ||
platforms: ${{ github.event_name == 'release' && env.release_arch || (github.event.inputs.platforms || env.dev_arch) }} | ||
push: false | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |