blob: 361d71d98d2c928c650315bfafeb67bad263cf95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
name: upload to registry
# this is for uploading images to a container registry when
# changes are made to `main`
on:
check_suite:
types: [completed]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64v8]
# https://github.com/sellout/bash-strict-mode/commit/9bf1d65c2f786a9887facfcb81e06d8b8b5f4667
if: github.event.check_suite.app.name == 'Garnix CI'
&& github.event.check_suite.conclusion == 'success'
&& github.event.check_suite.latest_check_runs_count > 1
&& github.event.check_suite.head_branch == 'main'
steps:
- uses: actions/checkout@v4
- name: install nix
uses: DeterminateSystems/nix-installer-action@v7
- uses: DeterminateSystems/magic-nix-cache-action@v2
- name: build docker image
id: build
run: |
nix build -L --accept-flake-config .#container-${{ matrix.arch }}
[ ! -L result ] && exit 1
echo "path=$(realpath result)" >> "$GITHUB_OUTPUT"
- name: upload image
uses: actions/upload-artifact@v3
with:
name: container-${{ matrix.arch }}
path: ${{ steps.build.outputs.path }}
if-no-files-found: error
retention-days: 1
upload:
needs: build
runs-on: ubuntu-latest
permissions:
packages: write
env:
REGISTRY: ghcr.io
USERNAME: getchoo
# ditto
if: github.event.check_suite.app.name == 'Garnix CI'
&& github.event.check_suite.conclusion == 'success'
&& github.event.check_suite.latest_check_runs_count > 1
&& github.event.check_suite.head_branch == 'main'
steps:
- name: set image name
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
- uses: actions/checkout@v4
- name: download images
uses: actions/download-artifact@v3
with:
path: images
- name: login to registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ github.token }}
- name: upload to registry
env:
TAG: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
run: |
set -eux
architectures=("amd64" "arm64v8")
for arch in "${architectures[@]}"; do
docker load < images/container-"$arch"/*.tar.gz
docker tag ${{ env.IMAGE_NAME }}:latest-"$arch" ${{ env.TAG }}-"$arch"
docker push ${{ env.TAG }}-"$arch"
done
docker manifest create ${{ env.TAG }} \
--amend ${{ env.TAG }}-amd64 \
--amend ${{ env.TAG }}-arm64v8
docker manifest push ${{ env.TAG }}
|