Skip to content

Commit

Permalink
build: github packages(docker) workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
inon-man committed Jul 21, 2024
1 parent 51a080f commit 15aa184
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Docker Build

on:
pull_request:
branches:
- main
- test
push:
branches:
- main
- test
tags:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v3

# https://docs.docker.com/build/ci/github-actions/multi-platform/
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# # https://github.com/docker/login-action
# - name: Login to DockerHub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to the github container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
images: |
ghcr.io/${{ github.repository }}
tags: |
type=sha
type=edge,branch=test
type=semver,pattern={{tag}}
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Build docker image
uses: docker/build-push-action@v3
with:
push: ${{ github.event_name != 'pull_request' }}
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ env.DOCKER_METADATA_OUTPUT_TAGS }}
labels: ${{ env.DOCKER_METADATA_OUTPUT_LABELS }}

0 comments on commit 15aa184

Please sign in to comment.