-
Notifications
You must be signed in to change notification settings - Fork 11
84 lines (72 loc) · 2.83 KB
/
build_website.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
# for comment on PR, follow instruction for: https://github.com/marketplace/actions/sticky-pull-request-comment
name: Aqualink Website CI
on:
# Run on all pull requests and on pushes to main.
pull_request:
paths:
- 'packages/website/**'
push:
branches:
- master
jobs:
website_test_build_and_deploy:
runs-on: ubuntu-22.04
env:
REACT_APP_MAPBOX_ACCESS_TOKEN: ${{ secrets.REACT_APP_MAPBOX_ACCESS_TOKEN }}
REACT_APP_SOFAR_API_TOKEN: ${{ secrets.REACT_APP_SOFAR_API_TOKEN }}
REACT_APP_FIREBASE_API_KEY: ${{ secrets.REACT_APP_FIREBASE_API_KEY }}
surge_url: aqualink-app-${{ github.event.pull_request.number }}.surge.sh
REACT_APP_API_BASE_URL: ${{ vars.REACT_APP_API_BASE_URL }}
REACT_APP_FEATURED_SITE_ID: ${{ vars.REACT_APP_FEATURED_SITE_ID }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies if needed.
id: install
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: |
yarn install --ignore-engines --frozen-lockfile
- name: Run website lint
if: success() || steps.install.conclusion == 'skipped'
working-directory: packages/website
run: yarn lint
- name: Run website tests
if: success() || steps.install.conclusion == 'skipped' || steps.install.conclusion == 'success'
working-directory: packages/website
run: yarn test
- name: Build website
id: build_website
if: success() || steps.install.conclusion == 'skipped' || steps.install.conclusion == 'success'
working-directory: packages/website
run: yarn build
- name: Deploy pull request on surge
if: steps.build_website.outcome == 'success' && github.event.pull_request.number != null
uses: dswistowski/surge-sh-action@v1
with:
domain: ${{ env.surge_url }}
project: "packages/website/build/."
login: ${{ secrets.surge_login }}
token: ${{ secrets.surge_token }}
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
- name: Comment PR
uses: marocchino/sticky-pull-request-comment@v1
continue-on-error: true
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
Build succeeded and deployed at https://${{ env.surge_url }}
(hash ${{ github.event.pull_request.head.sha }} deployed at ${{ steps.date.outputs.date }})