Skip to content

Commit

Permalink
docker: Add GH actions build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
janw committed Sep 6, 2023
1 parent 1871a93 commit 4a80ae7
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Docker Build

on:
push:
branches:
- "master"
tags:
- "*"
pull_request:

env:
build_platforms: ${{ vars.BUILD_PLATFORMS || 'linux/amd64,linux/arm64/v8' }}
build_image: ${{ vars.BUILD_IMAGE || 'ghcr.io/isso-comments/isso' }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
flavor: |
latest=false
images: ${{ env.build_image }}
tags: |
type=ref,event=pr
type=semver,pattern={{major}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- name: Login to Github Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ env.build_platforms }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

0 comments on commit 4a80ae7

Please sign in to comment.