-
Notifications
You must be signed in to change notification settings - Fork 6
171 lines (164 loc) · 5.85 KB
/
release.yml
File metadata and controls
171 lines (164 loc) · 5.85 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Deploy to Production Environment
# This workflow will trigger on any tag/release created on *any* branch
# Make sure to create tags/releases only from the "master" branch for consistency
on:
release:
types: [published]
jobs:
lint-client:
name: Lint and Build client
if: github.event.release.target_commitish == 'master'
runs-on: ubuntu-latest
env:
REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }}
REACT_APP_FIREBASE_API_KEY: ${{ secrets.REACT_APP_FIREBASE_API_KEY }}
REACT_APP_FIREBASE_AUTHDOMAIN: ${{ secrets.REACT_APP_FIREBASE_AUTHDOMAIN }}
REACT_APP_FIREBASE_PROJECT_ID: ${{ secrets.REACT_APP_FIREBASE_PROJECT_ID }}
REACT_APP_FIREBASE_STORAGE_BUCKET: ${{ secrets.REACT_APP_FIREBASE_STORAGE_BUCKET }}
REACT_APP_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.REACT_APP_FIREBASE_MESSAGING_SENDER_ID }}
REACT_APP_FIREBASE_APP_ID: ${{ secrets.REACT_APP_FIREBASE_APP_ID }}
REACT_APP_FIREBASE_MEASUREMENT_ID: ${{ secrets.REACT_APP_FIREBASE_MEASUREMENT_ID }}
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Use NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies and lint
run: |
cd client
npm install
npm run lint
- name: Build client
run: |
cd client
npm run build
- name: Archive Development Artifact
uses: actions/upload-artifact@v4
with:
name: build
include-hidden-files: true
path: |
client/build
client/.firebaserc
client/firebase.json
retention-days: 3
lint-server:
name: Lint Server
if: github.event.release.target_commitish == 'master'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Use NodeJS ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies and lint
run: |
cd server
npm install
npm run lint
deploy-client:
name: Deploy Client to Firebase Hosting
if: github.event.release.target_commitish == 'master'
needs: lint-client
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v4
with:
name: build
- name: Deploy to Firebase
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting:master
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
deploy-server:
if: ${{ vars.IS_DEPLOY_SERVER == 'heroku' }}
name: Deploy Server to Heroku
needs: lint-server
runs-on: ubuntu-latest
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_EMAIL: ${{ secrets.HEROKU_EMAIL }}
HEROKU_APP: ${{ secrets.HEROKU_APP }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- run: |
cat >~/.netrc <<EOF
machine api.heroku.com
login $HEROKU_EMAIL
password $HEROKU_API_KEY
machine git.heroku.com
login $HEROKU_EMAIL
password $HEROKU_API_KEY
EOF
- run: heroku git:remote -a $HEROKU_APP
- run: git push heroku HEAD:refs/heads/master
- run: rm -r -f .netrc
# Push the complete "app" Docker image
docker-build-push:
name: Push App Docker
if: github.event.release.target_commitish == 'master'
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Create temporary env variables
# Replace these files with actual values during
# runtime on 'docker-compose up'
run: |
cp client/.env.example client/.env
cp server/.env.example server/.env
- name: Set release version number
run: sed -i -e "s/latest/${{ github.event.release.tag_name }}/g" docker-compose.app.yml
- name: Build Images
run: docker compose -f docker-compose.app.yml build
- name: Push Images to Docker Hub
run: docker compose -f docker-compose.app.yml push
# Push the development (client/server) Docker images
docker-build-push-dev:
name: Push Dev Docker
if: github.event.release.target_commitish == 'master' && vars.DOCKERHUB_USERNAME != ''
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Create temporary env variables
run: |
cp client/.env.example client/.env
cp server/.env.example server/.env
- name: Build Images
run: docker compose -f docker-compose.dev.yml build
- name: Push Images to Docker Hub
run: docker compose -f docker-compose.dev.yml push