Skip to content

Commit 072bd91

Browse files
committed
Add GitHub Actions workflow to build grading-base images
1 parent adfd8d4 commit 072bd91

3 files changed

Lines changed: 96 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Build and push Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- '[0-9]*'
8+
9+
jobs:
10+
build:
11+
name: Build (${{ matrix.platform }})
12+
runs-on: ${{ matrix.runner }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
include:
17+
- platform: linux/amd64
18+
runner: ubuntu-24.04
19+
- platform: linux/arm64
20+
runner: ubuntu-24.04-arm
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Log in to Docker Hub
26+
uses: docker/login-action@v3
27+
with:
28+
username: ${{ secrets.DOCKERHUB_USERNAME }}
29+
password: ${{ secrets.DOCKERHUB_TOKEN }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
34+
# Build and push platform-specific digest (no manifest tag yet)
35+
- name: Build and push by digest
36+
id: build
37+
uses: docker/build-push-action@v6
38+
with:
39+
context: .
40+
platforms: ${{ matrix.platform }}
41+
push: true
42+
outputs: type=image,name=apluslms/grading-base,push-by-digest=true,name-canonical=true
43+
44+
# Save the digest so the merge job can find it
45+
- name: Export digest
46+
run: |
47+
mkdir -p /tmp/digests
48+
digest="${{ steps.build.outputs.digest }}"
49+
touch "/tmp/digests/${digest#sha256:}"
50+
51+
- name: Upload digest artifact
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: digest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
55+
path: /tmp/digests/*
56+
retention-days: 1
57+
58+
merge:
59+
name: Merge manifests
60+
runs-on: ubuntu-24.04
61+
needs: build
62+
63+
steps:
64+
- name: Download digests
65+
uses: actions/download-artifact@v4
66+
with:
67+
path: /tmp/digests
68+
pattern: digest-*
69+
merge-multiple: true
70+
71+
- name: Log in to Docker Hub
72+
uses: docker/login-action@v3
73+
with:
74+
username: ${{ secrets.DOCKERHUB_USERNAME }}
75+
password: ${{ secrets.DOCKERHUB_TOKEN }}
76+
77+
- name: Set up Docker Buildx
78+
uses: docker/setup-buildx-action@v3
79+
80+
- name: Determine tags
81+
id: meta
82+
uses: docker/metadata-action@v5
83+
with:
84+
images: apluslms/grading-base
85+
flavor: |
86+
latest=false
87+
tags: |
88+
type=raw,enable=${{ github.ref == 'refs/heads/master' }},value=latest
89+
type=ref,enable=${{ github.ref != 'refs/heads/master' }},event=branch
90+
91+
- name: Create and push multi-arch manifest
92+
working-directory: /tmp/digests
93+
run: |
94+
docker buildx imagetools create \
95+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
96+
$(printf 'apluslms/grading-base@sha256:%s ' *)

hooks/build

Lines changed: 0 additions & 10 deletions
This file was deleted.

hooks/push

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)