Skip to content

Commit dd01707

Browse files
jordijordipiqueselles
jordi
authored andcommitted
Use Github Actions to build and publish the docker image
This commit reverts #21 so we use Github Actions again to build and publish the docker images, now that some of the actions related to building docker images have been whitelisted in the ThoughtMachine org. The docker images built as part of a release are published to ghcr.
1 parent 7ec6b28 commit dd01707

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish Docker 🐳 images 📦 to GitHub Container Registry
2+
3+
on:
4+
push:
5+
tags:
6+
- '**'
7+
8+
jobs:
9+
build-and-publish-to-ghcr:
10+
# Explicitly grant the `secrets.GITHUB_TOKEN` permissions.
11+
permissions:
12+
# Grant the ability to write to GitHub Packages (push Docker images to
13+
# GitHub Container Registry).
14+
packages: write
15+
name: Build and publish Docker 🐳 images 📦 to GitHub Container Registry
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout main
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Extract metadata (tags, labels) for Docker
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: ghcr.io/${{ github.repository }}
28+
29+
- name: Write version
30+
run: ./scripts/insert-version-pyproject.sh ${{github.ref_name}}
31+
32+
- name: Set up QEMU
33+
uses: docker/setup-qemu-action@v3
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
38+
- name: Login to GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
# This is the user that triggered the Workflow. In this case, it will
43+
# either be the user whom created the Release or manually triggered
44+
# the workflow_dispatch.
45+
username: ${{ github.actor }}
46+
# `secrets.GITHUB_TOKEN` is a secret that's automatically generated by
47+
# GitHub Actions at the start of a workflow run to identify the job.
48+
# This is used to authenticate against GitHub Container Registry.
49+
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
50+
# for more detailed information.
51+
password: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Build and push image
54+
uses: docker/build-push-action@v5
55+
with:
56+
push: true # push the image to ghcr
57+
tags: >
58+
ghcr.io/thought-machine/generic-k8s-webhook:${{github.sha}},
59+
ghcr.io/thought-machine/generic-k8s-webhook:${{github.ref_name}}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
platforms: linux/amd64,linux/arm64

.github/workflows/test-pr.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,21 @@ jobs:
3434

3535
- name: Run unittests
3636
run: make unittests
37+
38+
build-docker-image:
39+
name: Build docker image
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Setup Action
43+
uses: actions/checkout@v3
44+
with:
45+
fetch-depth: 0
46+
47+
- name: Set up QEMU
48+
uses: docker/setup-qemu-action@v3
49+
50+
- name: Set up Docker Buildx
51+
uses: docker/setup-buildx-action@v3
52+
53+
- name: Build image
54+
uses: docker/build-push-action@v5

0 commit comments

Comments
 (0)