Skip to content

Commit a76400a

Browse files
authored
Add updated csesoc website deployment CI/CD (#47)
1 parent fd0dd50 commit a76400a

File tree

4 files changed

+113
-67
lines changed

4 files changed

+113
-67
lines changed

.github/workflows/backend-ci.yml

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

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- renovate/*
8+
pull_request:
9+
branches:
10+
- master
11+
12+
jobs:
13+
api-ci:
14+
runs-on: ubuntu-latest
15+
defaults:
16+
run:
17+
working-directory: ./backend
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: actions/setup-node@v3
21+
with:
22+
node-version: 22
23+
- run: npm ci
24+
- run: npm run type-check
25+
- run: npm run build
26+
ui-ci:
27+
runs-on: ubuntu-latest
28+
defaults:
29+
run:
30+
working-directory: ./frontend
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-node@v3
34+
with:
35+
node-version: 16
36+
- run: npm install
37+
- run: npm run lint
38+
- run: npm run type-check
39+
- run: npm run build

.github/workflows/docker.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Docker
2+
on:
3+
push:
4+
branches:
5+
- "master"
6+
7+
jobs:
8+
build:
9+
name: "Build (${{ matrix.component }})"
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
component: [backend, frontend]
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
- name: Set up QEMU
22+
uses: docker/setup-qemu-action@v3
23+
with:
24+
platforms: arm64
25+
- name: Set up Docker Buildx
26+
uses: docker/setup-buildx-action@v3
27+
- name: Log into registry ${{ env.REGISTRY }}
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ghcr.io
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GH_TOKEN }}
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: ${{ matrix.component }}
37+
push: ${{ github.event_name != 'pull_request' }}
38+
platforms: linux/amd64
39+
file: ${{ matrix.component }}/Dockerfile
40+
tags: |
41+
ghcr.io/csesoc/website-${{ matrix.component }}:${{ github.sha }}
42+
ghcr.io/csesoc/website-${{ matrix.component }}:latest
43+
labels: ${{ steps.meta.outputs.labels }}
44+
deploy-prod:
45+
name: Deploy Production (CD)
46+
runs-on: ubuntu-latest
47+
needs: [build]
48+
concurrency: prod
49+
environment:
50+
name: prod
51+
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }}
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v4
55+
with:
56+
repository: csesoc/deployment
57+
token: ${{ secrets.GH_TOKEN }}
58+
ref: develop
59+
- name: Install yq - portable yaml processor
60+
uses: mikefarah/[email protected]
61+
- name: Update deployment
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
64+
run: |
65+
git config user.name "CSESoc CD"
66+
git config user.email "[email protected]"
67+
git checkout -b update/website-prod/${{ github.sha }}
68+
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-backend:${{ github.sha }}"' apps/projects/website/prod/deploy-backend.yml
69+
yq -i '.items[0].spec.template.spec.containers[0].image = "ghcr.io/csesoc/website-frontend:${{ github.sha }}"' apps/projects/website/prod/deploy-frontend.yml
70+
git add .
71+
git commit -m "feat(website/prod): update image"
72+
git push -u origin update/website-prod/${{ github.sha }}
73+
gh pr create -B develop --title "feat(website/prod): update image" --body "Updates the image for the website-prod deployment to commit csesoc/csesoc-website@${{ github.sha }}." > URL
74+
gh pr merge $(cat URL) --squash -d

.github/workflows/frontend-ci.yml

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

0 commit comments

Comments
 (0)