Skip to content

Commit a2827fd

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

3 files changed

Lines changed: 97 additions & 13 deletions

File tree

.github/workflows/build.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
file: docker/Dockerfile
41+
platforms: ${{ matrix.platform }}
42+
push: true
43+
outputs: type=image,name=apluslms/grading-base,push-by-digest=true,name-canonical=true
44+
45+
# Save the digest so the merge job can find it
46+
- name: Export digest
47+
run: |
48+
mkdir -p /tmp/digests
49+
digest="${{ steps.build.outputs.digest }}"
50+
touch "/tmp/digests/${digest#sha256:}"
51+
52+
- name: Upload digest artifact
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: digest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
56+
path: /tmp/digests/*
57+
retention-days: 1
58+
59+
merge:
60+
name: Merge manifests
61+
runs-on: ubuntu-24.04
62+
needs: build
63+
64+
steps:
65+
- name: Download digests
66+
uses: actions/download-artifact@v4
67+
with:
68+
path: /tmp/digests
69+
pattern: digest-*
70+
merge-multiple: true
71+
72+
- name: Log in to Docker Hub
73+
uses: docker/login-action@v3
74+
with:
75+
username: ${{ secrets.DOCKERHUB_USERNAME }}
76+
password: ${{ secrets.DOCKERHUB_TOKEN }}
77+
78+
- name: Set up Docker Buildx
79+
uses: docker/setup-buildx-action@v3
80+
81+
- name: Determine tags
82+
id: meta
83+
uses: docker/metadata-action@v5
84+
with:
85+
images: apluslms/grading-base
86+
flavor: |
87+
latest=false
88+
tags: |
89+
type=raw,enable=${{ github.ref == 'refs/heads/master' }},value=latest
90+
type=ref,enable=${{ github.ref != 'refs/heads/master' }},event=branch
91+
92+
- name: Create and push multi-arch manifest
93+
working-directory: /tmp/digests
94+
run: |
95+
docker buildx imagetools create \
96+
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
97+
$(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)