Skip to content

Commit 6ca81e2

Browse files
committed
feat: add automated container build
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 #80 Signed-off-by: Jonathan Gonzalez V <[email protected]>
1 parent 2ea9414 commit 6ca81e2

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

.github/workflows/docker-build.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,52 @@ name: Docker Image CI
22

33
on: [push, pull_request]
44

5+
env:
6+
REGISTRY: ghcr.io
7+
IMAGE_NAME: ${{ github.repository }}
8+
59
jobs:
610

711
docker-build:
8-
912
runs-on: ubuntu-latest
10-
13+
permissions:
14+
contents: read
15+
packages: write
1116
steps:
1217
- name: Checkout
1318
uses: actions/checkout@v3
14-
- name: Build the Docker image
15-
run: docker build . --file Dockerfile --tag spellcheck:$(date +%s)
19+
20+
- name: Set up QEMU
21+
uses: docker/[email protected]
22+
with:
23+
image: tonistiigi/binfmt:qemu-v6.2.0
24+
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v1
27+
with:
28+
install: true
29+
30+
- name: Login to GitHub Registry
31+
uses: docker/[email protected]
32+
with:
33+
registry: ${{ env.REGISTRY }}
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Metadata for the image
38+
id: meta
39+
uses: docker/metadata-action@v4
40+
with:
41+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
42+
tags: |
43+
type=ref,event=branch
44+
type=ref,event=pr
45+
type=semver,pattern={{version}}
46+
47+
- name: Build container
48+
uses: docker/[email protected]
49+
with:
50+
platforms: "linux/amd64, linux/arm64"
51+
context: .
52+
push: true
53+
tags: ${{ steps.meta.outputs.tags }}

0 commit comments

Comments
 (0)