-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (95 loc) · 3.56 KB
/
Copy pathbuild.yml
File metadata and controls
117 lines (95 loc) · 3.56 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
name: Build
on:
push:
branches:
- main
paths:
- src/**/**.cs
- src/**/*.csproj
- src/**/package.nix
- src/**/deps.json
- src/**/Dockerfile
- src/Dashboard/Pages/*.cshtml
- default.nix
- lon.nix
- lon.lock
- .github/workflows/build.yml
workflow_dispatch:
jobs:
Build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
packages: write
steps:
- uses: actions/checkout@v6
- name: Install Lix
uses: samueldr/lix-gha-installer-action@v2025-02-26.prerelease
- name: Install Cachix
uses: cachix/cachix-action@v16
with:
name: drakon64
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build
run: cachix watch-exec drakon64 -- nix-build -A repository.docker -A dashboard.docker -A client
- name: Upload to Cachix
run: cachix push drakon64 $(nix eval --file default.nix --raw repository.docker) $(nix eval --file default.nix --raw dashboard.docker) $(nix eval --file default.nix --raw client)
- name: Create Cachix pins
run: |
cachix pin drakon64 anamnesis "$(nix eval --file default.nix --raw repository.docker)" --keep-revisions 1
cachix pin drakon64 anamnesis-dashboard "$(nix eval --file default.nix --raw dashboard.docker)" --keep-revisions 1
cachix pin drakon64 anamnesis-client "$(nix eval --file default.nix --raw client)" --keep-revisions 1
- run: |
docker load < result
docker load < result-2
- name: Login to GitHub Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Repository to GitHub Packages
uses: docker/build-push-action@v6
with:
context: src/Repository
push: true
tags: ghcr.io/drakon64/anamnesis:latest
env:
SOURCE_DATE_EPOCH: 0
- name: Upload Dashboard to GitHub Packages
uses: docker/build-push-action@v6
with:
context: src/Dashboard
push: true
tags: ghcr.io/drakon64/anamnesis-dashboard:latest
env:
SOURCE_DATE_EPOCH: 0
Deploy:
needs:
- Build
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v6
- name: Install Lix
uses: samueldr/lix-gha-installer-action@v2025-02-26.prerelease
- name: Install Cachix
uses: cachix/cachix-action@v16
with:
name: drakon64
- name: Build Nix shell
run: nix-shell -A opentofu --run "exit"
- uses: google-github-actions/auth@v3
with:
project_id: ${{ secrets.GCP_PROJECT }}
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
- name: Deploy to Cloud Run
run: |
echo "$TERRAFORM_TFVARS" | base64 -d > terraform.tfvars
nix-shell -A opentofu ../shell.nix --run "tofu init"
nix-shell -A opentofu ../shell.nix --run "tofu apply -auto-approve -target 'module.anamnesis.google_cloud_run_v2_service.dashboard[\"europe-west1\"]' -target 'module.anamnesis.google_cloud_run_v2_service.dashboard[\"europe-west4\"]' -target 'module.anamnesis.google_cloud_run_v2_service.repository[\"europe-west1\"]' -target 'module.anamnesis.google_cloud_run_v2_service.repository[\"europe-west4\"]'"
working-directory: tofu
env:
TERRAFORM_TFVARS: ${{ secrets.TERRAFORM_TFVARS }}