-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (125 loc) · 4.18 KB
/
build-and-deploy.yaml
File metadata and controls
132 lines (125 loc) · 4.18 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# ========================================
# Note: If you make changes to this CI/CD, please include someone from DevOps in the list of reviewers for the PR.
# ========================================
name: Build and Deploy
on: push
jobs:
backend-check:
name: "Backend Check"
uses: pennlabs/shared-actions/.github/workflows/django.yaml@238aa5ee908afba9f906641b51f82bb81572f66a
secrets: inherit
with:
projectName: pennmobile
path: backend
pythonVersion: 3.11-bookworm
flake: true
black: true
ruff: false
frontend-check:
name: "Frontend Check"
uses: pennlabs/shared-actions/.github/workflows/react.yaml@238aa5ee908afba9f906641b51f82bb81572f66a
with:
path: frontend
imageName: penn-mobile-frontend
nodeVersion: 20.11.1
githubRef: ${{ github.ref }}
gitSha: ${{ github.sha }}
skipCodecov: true
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
build-backend:
name: Build backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-build-backend
- name: Build/Publish
uses: docker/build-push-action@v6
with:
context: backend
file: backend/Dockerfile
push: false
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/penn-mobile-backend:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/penn-mobile-backend:latest,pennlabs/penn-mobile-backend:${{ github.sha }}
outputs: type=docker,dest=/tmp/image.tar
- uses: actions/upload-artifact@v4
with:
name: build-backend
path: /tmp/image.tar
needs: backend-check
build-frontend:
name: Build frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: buildx-build-frontend
- name: Build/Publish
uses: docker/build-push-action@v6
with:
context: frontend
file: frontend/Dockerfile
push: false
cache-from: type=local,src=/tmp/.buildx-cache,type=registry,ref=pennlabs/penn-mobile-frontend:latest
cache-to: type=local,dest=/tmp/.buildx-cache
tags: pennlabs/penn-mobile-frontend:latest,pennlabs/penn-mobile-frontend:${{ github.sha }}
outputs: type=docker,dest=/tmp/image.tar
- uses: actions/upload-artifact@v4
with:
name: build-frontend
path: /tmp/image.tar
needs: frontend-check
publish:
name: Publish Images
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: build-*
- uses: geekyeggo/delete-artifact@v5
with:
name: |-
build-backend
build-frontend
- name: Load docker images
run: |-
docker load --input build-backend/image.tar
docker load --input build-frontend/image.tar
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push docker images
run: |-
docker push -a pennlabs/penn-mobile-backend
docker push -a pennlabs/penn-mobile-frontend
needs:
- build-backend
- build-frontend
deploy:
name: "Deploy"
uses: pennlabs/shared-actions/.github/workflows/deployment.yaml@v0.1.9
with:
githubRef: ${{ github.ref }}
gitSha: ${{ github.sha }}
secrets:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
GH_AWS_ACCESS_KEY_ID: ${{ secrets.GH_AWS_ACCESS_KEY_ID }}
GH_AWS_SECRET_ACCESS_KEY: ${{ secrets.GH_AWS_SECRET_ACCESS_KEY }}
needs:
- publish