-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (89 loc) · 2.79 KB
/
deploy_prod.yml
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
# Sample workflow for building and deploying a Gatsby site to GitHub Pages
#
# To get started with Gatsby see: https://www.gatsbyjs.com/docs/quick-start/
#
name: Build and deploy prod
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
# Default to bash
defaults:
run:
shell: bash
jobs:
# Build job
build:
environment:
name: prod
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "14"
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Configure CNAME
run: echo "${{ vars.SITE_URL }}" > static/CNAME
- name: Set backend server
run: echo "export default '${{ vars.BACKEND_URL }}'" > src/utils/serverUrl.js
- name: Build project
env:
NODE_ENV: production
run: npm run build
- name: Move build folder
run: mv ./public ../build
- name: Check working directory
run: echo $(pwd)
working-directory: ../build
- name: Initialize git
run: git init
working-directory: ../build
- name: Set user email
run: git config --local user.email "${{ vars.SVC_EMAIL }}"
working-directory: ../build
- name: Set user name
run: git config --local user.name "${{ vars.SVC_NAME }}"
working-directory: ../build
- name: Set user password
working-directory: ../build
run: git config --local user.password ${{ secrets.SVC_TOKEN }}
- name: Configure git env
working-directory: ../build
run: echo "GIT_USER=${{ vars.SVC_NAME }}:${{ secrets.SVC_TOKEN }}" >> $GITHUB_ENV
- name: Set remote url
working-directory: ../build
run: git remote add origin https://${{ vars.SVC_NAME }}:${{ secrets.SVC_TOKEN }}@${{ vars.GH_PAGES_REPO }}
- name: Fetch from remote url
working-directory: ../build
run: git fetch
- name: Add all files
working-directory: ../build
run: git add .
- name: Commit to master
working-directory: ../build
run: git commit -m "Updated code"
- name: Push code to origin
working-directory: ../build
run: git push -f origin master
- name: Check site deployed
working-directory: ../build
run: echo "Site deployed ${{ vars.SITE_URL }}"
- name: Delete build folder
working-directory: ../
run: rm -rf build