-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (61 loc) · 1.63 KB
/
build.yaml
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
name: Build
on:
- push
permissions:
contents: read
id-token: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
services:
test_db:
image: postgres:16
env:
POSTGRES_USER: sgs
POSTGRES_PASSWORD: sgs-pass
ports:
- 5433:5432
volumes:
- test_data:/var/lib/postgresql/data
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v11
- uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Run tests
run: nix develop -c make check
build:
name: Build
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@v11
- uses: DeterminateSystems/magic-nix-cache-action@v6
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image
run: nix build -L .#image
- uses: actions/upload-artifact@v4
with:
name: image
path: result
- name: Push image
if: github.ref_type == 'tag'
run: |
image="$(docker load -i result | awk '{print $3}')"
<<< "$TAGS" xargs -n1 docker tag "$image"
<<< "$TAGS" xargs -n1 docker push
env:
TAGS: ${{ steps.meta.outputs.tags }}