Skip to content

Commit 0950af7

Browse files
committed
CI to GHCR rather than docker
1 parent 34f2fd0 commit 0950af7

5 files changed

Lines changed: 12 additions & 96 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,18 @@ jobs:
1919
permissions:
2020
contents: read
2121
id-token: write
22+
packages: write
2223

2324
steps:
2425
- name: Checkout code
2526
uses: actions/checkout@v4
2627

27-
- name: Login to Google Cloud
28-
id: gcp-auth
29-
uses: google-github-actions/auth@v2
30-
with:
31-
token_format: "access_token"
32-
project_id: ${{ secrets.GCP_PROJECT_ID }}
33-
workload_identity_provider: ${{ secrets.GCP_WLIF_PROVIDER }}
34-
service_account: ${{ secrets.GCP_SA }}
35-
access_token_lifetime: 600s
36-
37-
- name: Login to Docker Hub
28+
- name: Login to GitHub Container Registry
3829
uses: docker/login-action@v2
3930
with:
40-
username: ${{ secrets.DOCKER_USERNAME }}
41-
password: ${{ secrets.DOCKER_PASSWORD }}
31+
registry: ghcr.io
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
4234

4335
- name: Restore build cache
4436
uses: actions/cache/restore@v4
@@ -94,72 +86,26 @@ jobs:
9486
DATABASE_URL: ${{ secrets.DATABASE_URL }}
9587

9688
- name: Install dependencies and run postinstall
97-
run: |
98-
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" > src-api/.env
99-
bun i
100-
env:
101-
DATABASE_URL: ${{ secrets.DATABASE_URL }}
102-
103-
- name: Build API
104-
working-directory: src-api
105-
run: cargo build --release --locked --no-default-features
89+
run: bun i
10690
env:
10791
DATABASE_URL: ${{ secrets.DATABASE_URL }}
10892

109-
- name: Build API image
110-
run: docker build . -t onlycs/attendance:api -f Dockerfile.api
111-
11293
- name: Generate static site
11394
run: bun generate
11495

115-
- name: Build API (include static assets)
96+
- name: Build API
11697
working-directory: src-api
11798
run: cargo build --release --locked
11899
env:
119100
DATABASE_URL: ${{ secrets.DATABASE_URL }}
120101

121102
- name: Build standard image
122-
run: docker build . -t onlycs/attendance:latest
103+
run: docker build . -t ghcr.io/${{ github.repository }}:latest
123104

124105
- name: Push Docker images
125106
run: |
126-
docker push onlycs/attendance:api
127-
docker push onlycs/attendance:latest
128-
129-
- name: Regenerate frontend for ourselves
130-
run: |
131-
rm -rf .output
132-
echo "NUXT_PUBLIC_API_URL=${{ secrets.API_URL }}" > .env
133-
bun generate
134-
env:
135-
API_URL: ${{ secrets.API_URL }}
136-
137-
- name: Deploy API to GCE
138-
run: |
139-
gcloud compute ssh attendance-vm \
140-
--zone=us-central1-a \
141-
--tunnel-through-iap \
142-
--command="
143-
sudo docker pull onlycs/attendance:api &&
144-
sudo docker stop attendance || true &&
145-
sudo docker rm attendance || true &&
146-
sudo docker run -d \
147-
--name attendance \
148-
--restart always \
149-
--network=attendance-net \
150-
-e DATABASE_URL='${{ secrets.DATABASE_URL }}' \
151-
-e JWT_SECRET='${{ secrets.JWT_SECRET }}' \
152-
-p 8080:8080 \
153-
onlycs/attendance:api
154-
"
155-
156-
- name: Deploy Static to Firebase Hosting
157-
uses: FirebaseExtended/action-hosting-deploy@v0
158-
with:
159-
repoToken: ${{ secrets.GITHUB_TOKEN }}
160-
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_RIVER_WAVE_445602_N7 }}
161-
channelId: live
162-
projectId: ${{ secrets.GCP_PROJECT_ID }}
107+
docker push ghcr.io/${{ github.repository }}:api
108+
docker push ghcr.io/${{ github.repository }}:latest
163109
164110
- name: Save Build cache
165111
if: always()

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ src-api/openapi.yml
3333

3434
.firebaserc
3535
.firebase
36+
firebase.json

app/plugins/api.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,7 @@ function error(
7878
export type ApiClient = NuxtApp["$api"];
7979

8080
export default defineNuxtPlugin(() => {
81-
const runtime = useRuntimeConfig();
82-
83-
const url = [
84-
runtime.public.apiUrl,
85-
import.meta.dev ? "http://localhost:8080/" : "/api",
86-
].find((u) => !!u)!;
81+
const url = import.meta.dev ? "http://localhost:8080/" : "/api";
8782

8883
hclient.setConfig({
8984
baseUrl: url,

firebase.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

nuxt.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ export default defineNuxtConfig({
8585
collections: ["hugeicons"],
8686
},
8787
},
88-
runtimeConfig: {
89-
public: {
90-
apiUrl: process.env.API_URL,
91-
},
92-
},
9388
ssr: false,
9489
compatibilityDate: "2025-08-18",
9590
});

0 commit comments

Comments
 (0)