Skip to content

Commit

Permalink
feat: add automated container build
Browse files Browse the repository at this point in the history
Use the `docker/build-push` and `docker/metadata` actions to build
a container and add the proper tag depending on the branch, PR or
the tagged version using semver as the proper version.

Closes rojopolis#80

Signed-off-by: Jonathan Gonzalez V <[email protected]>
  • Loading branch information
sxd committed Aug 5, 2022
1 parent 2ea9414 commit 3bd98bf
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,52 @@ name: Docker Image CI

on: [push, pull_request]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

docker-build:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag spellcheck:$(date +%s)

- name: Set up QEMU
uses: docker/[email protected]
with:
image: tonistiigi/binfmt:qemu-v6.2.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
install: true

- name: Login to GitHub Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Metadata for the image
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}
- name: Build container
uses: docker/[email protected]
with:
platforms: "linux/amd64, linux/arm64"
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}

0 comments on commit 3bd98bf

Please sign in to comment.