@@ -10,12 +10,41 @@ jobs:
1010 build-backend :
1111 name : Build (Backend)
1212 runs-on : ubuntu-latest
13- if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
13+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/CHAOS-224-KHAOS-rewrite' }}
14+ services :
15+ postgres :
16+ image : postgres:16
17+ env :
18+ POSTGRES_USER : postgres
19+ POSTGRES_PASSWORD : password
20+ POSTGRES_DB : chaos
21+ ports :
22+ - 5432:5432
1423 steps :
1524 - uses : actions/checkout@v4
1625 with :
1726 submodules : true
1827 token : ${{ secrets.GH_TOKEN }}
28+ - name : Setup cargo cache
29+ uses : actions/cache@v3
30+ with :
31+ path : |
32+ ~/.cargo/bin/
33+ ~/.cargo/registry/index/
34+ ~/.cargo/registry/cache/
35+ ~/.cargo/git/db/
36+ backend/server/target/
37+ key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
38+ restore-keys : ${{ runner.os }}-cargo-
39+ - name : Setup temporary DB
40+ working-directory : backend
41+ run : |
42+ which sqlx || cargo install sqlx-cli --no-default-features --features native-tls,postgres
43+ echo "DATABASE_URL=postgres://postgres:password@localhost:5432/chaos" >> .env
44+ sqlx migrate run
45+ - name : Generate SQLx files
46+ working-directory : backend/server
47+ run : cargo sqlx prepare
1948 - name : Set up Docker Buildx
2049 id : buildx
2150 uses : docker/setup-buildx-action@master
@@ -40,33 +69,27 @@ jobs:
4069 context : backend
4170 builder : ${{ steps.buildx.outputs.name }}
4271 file : backend/Dockerfile
43- push : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main ' }}
72+ push : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/CHAOS-224-KHAOS-rewrite ' }}
4473 tags : |
4574 ghcr.io/devsoc-unsw/chaos-backend:${{ github.sha }}
46- ghcr.io/devsoc-unsw/chaos-backend:latest
75+ ghcr.io/devsoc-unsw/chaos-backend:staging- latest
4776 labels : ${{ steps.meta.outputs.labels }}
4877 cache-from : type=local,src=/tmp/.buildx-cache
49- # Note the mode=max here
50- # More: https://github.com/moby/buildkit#--export-cache-options
51- # And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue
5278 cache-to : type=local,mode=max,dest=/tmp/.buildx-cache-new
5379 - name : Move cache
5480 run : |
5581 rm -rf /tmp/.buildx-cache
5682 mv /tmp/.buildx-cache-new /tmp/.buildx-cache
57- build-client :
58- name : Build (Client )
83+ build-frontend :
84+ name : Build (Frontend )
5985 runs-on : ubuntu-latest
86+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/CHAOS-224-KHAOS-rewrite' }}
6087 permissions :
6188 contents : read
6289 packages : write
6390 steps :
6491 - name : Checkout repository
6592 uses : actions/checkout@v4
66- - name : Set up QEMU
67- uses : docker/setup-qemu-action@v2
68- with :
69- platforms : arm64
7093 - name : Set up Docker Buildx
7194 uses : docker/setup-buildx-action@v2
7295 - name : Log into registry ${{ env.REGISTRY }}
@@ -78,26 +101,23 @@ jobs:
78101 - name : Build and push Docker image
79102 uses : docker/build-push-action@v4
80103 with :
81- context : frontend
82- push : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main ' }}
104+ context : frontend-nextjs
105+ push : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/CHAOS-224-KHAOS-rewrite ' }}
83106 platforms : linux/amd64
84- file : frontend/Dockerfile
85- build-args : |
86- VITE_API_BASE_URL=${{ secrets.API_BASE_URL }}
87- VITE_OAUTH_CALLBACK_URL=${{ secrets.OAUTH_CALLBACK_URL }}
107+ file : frontend-nextjs/Dockerfile
88108 tags : |
89109 ghcr.io/devsoc-unsw/chaos-frontend:${{ github.sha }}
90- ghcr.io/devsoc-unsw/chaos-frontend:latest
110+ ghcr.io/devsoc-unsw/chaos-frontend:staging- latest
91111 labels : ${{ steps.meta.outputs.labels }}
92112 deploy :
93113 name : Deploy (CD)
94114 runs-on : ubuntu-latest
95- needs : [build-client , build-backend]
96- if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main ' }}
115+ needs : [build-frontend , build-backend]
116+ if : ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/CHAOS-224-KHAOS-rewrite ' }}
97117 concurrency : staging
98118 environment :
99119 name : staging
100- url : https://chaos.staging.csesoc.unsw.edu.au
120+ url : https://chaosstaging.devsoc.app
101121 steps :
102122 - name : Checkout repository
103123 uses : actions/checkout@v4
0 commit comments