aip.yml
1name: Build AIP
2
3on:
4 workflow_dispatch:
5 pull_request:
6 branches: [ main ]
7 paths: [ 'aip/**' ]
8 push:
9 branches: [ main ]
10 paths: [ 'aip/**' ]
11
12jobs:
13 build:
14 runs-on: ubuntu-latest
15 defaults:
16 run:
17 working-directory: aip
18
19 steps:
20 - name: Checkout code
21 uses: actions/checkout@v4
22
23 - name: Install Nix
24 uses: DeterminateSystems/nix-installer-action@main
25 with:
26 logger: pretty
27
28 - name: Setup Nix cache
29 uses: DeterminateSystems/magic-nix-cache-action@main
30
31 - name: Check flake
32 run: nix flake check
33
34 - name: Build Rust binary
35 run: nix build .#aip
36
37 - name: Build Docker image
38 run: nix build .#aipImg
39
40 - name: Load Docker image
41 run: docker load < result
42
43 - name: Test Docker image
44 run: |
45 # Start the container in the background with temp volume
46 docker run -d --name aip-test -p 8080:8080 \
47 -e EXTERNAL_BASE=http://localhost:8080 \
48 -e DPOP_NONCE_SEED=test-seed-for-ci \
49 -e DATABASE_URL=sqlite:///data/aip.db \
50 -v /tmp/aip-test:/data \
51 aip:latest
52
53 # Wait for the service to start
54 sleep 15
55
56 # Test the root endpoint
57 curl -f http://localhost:8080 || exit 1
58
59 # Stop the test container
60 docker stop aip-test
61 docker rm aip-test
62
63 - name: Save Docker image as artifact
64 # if: github.ref == 'refs/heads/main'
65 run: docker save aip:latest | gzip > aip-image.tar.gz
66
67 - name: Upload Docker image artifact
68 # if: github.ref == 'refs/heads/main'
69 uses: actions/upload-artifact@v4
70 with:
71 name: aip-docker-image
72 path: aip/aip-image.tar.gz
73 retention-days: 1