-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (52 loc) · 1.63 KB
/
ci.yml
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
build:
name: Build Image
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-23.11
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Login to GitHub container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
run: |
nix build
- name: Load image
id: image
run: |
image_id=$(docker load < result | sed -n 's/^Loaded image: //p')
echo "image_id=${image_id}" | tee "$GITHUB_ENV"
- name: Push image
run: |
image_name=${image_id%:*}
image_tags="canary"
if [[ "${{ github.event_name }}" == "release" ]]; then
image_tags="${{ github.event.release.tag_name }},latest"
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
image_tags="pr${{github.event.number}}"
fi
for image_tag in ${image_tags//,/ }
do
docker tag ${image_id} ghcr.io/${{ github.repository_owner }}/${image_name}:${image_tag}
docker push ghcr.io/${{ github.repository_owner }}/${image_name}:${image_tag}
done
- name: Inspect image
run: |
docker image inspect ${image_id}