This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (106 loc) · 3.35 KB
/
storefront.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Storefront
on:
push:
pull_request:
repository_dispatch:
types:
- next-rebuild
jobs:
build:
concurrency:
group: ${{ github.ref }}-storefront-build
cancel-in-progress: true
name: Build
runs-on: ubuntu-latest
defaults:
run:
working-directory: storefront
steps:
- name: Checkout Repo
uses: actions/checkout@master
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
cache-dependency-path: storefront/package-lock.json
- name: Install Dependencies
run: npm ci
# SWELL_SECRET_KEY is needed to next.js SSG
- name: Copy secrets
run: |
echo >> .env.production
echo SWELL_SECRET_KEY="${{ secrets.SWELL_SECRET_KEY }}" >> .env.production
- name: Nextjs build
run: |
npm run build
rm -rf ./.next/cache
- name: Archive Next.js Build Artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@master
with:
name: dist
path: storefront/.next
retention-days: 1
# public folder contains dynamically generated sitemap,
# therefore is stored as build artifact
- name: Archive Production Artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-artifact@master
with:
name: public
path: storefront/public
retention-days: 1
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
concurrency:
group: deploy-cloud-development
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout Repo
uses: actions/checkout@master
- uses: actions/setup-node@v3
with:
node-version: "16"
cache: "npm"
cache-dependency-path: firebase/functions/package-lock.json
- name: Install Dependencies
run: npm ci --prefix firebase/functions
- name: Download build Artifact
uses: actions/download-artifact@master
with:
name: dist
path: firebase/functions/nextjs/.next
- name: Download public Artifact
uses: actions/download-artifact@master
with:
name: public
path: firebase/storefront-public
- name: Copy next.js config
run: |
cp ./storefront/next.config.js ./firebase/functions/nextjs/next.config.cjs
- name: Copy Envs
run: cp storefront/.env* firebase/functions/
- name: Copy secrets
run: |
echo >> .env
echo SESSION_PASSWORD="${{ secrets.SESSION_PASSWORD }}" >> .env
echo SWELL_SECRET_KEY="${{ secrets.SWELL_SECRET_KEY }}" >> .env
echo INFURA_MAINNET="${{ secrets.INFURA_MAINNET }}" >> .env
echo INFURA_TESTNET="${{ secrets.INFURA_TESTNET }}" >> .env
working-directory: firebase/functions
- name: Deploy Firebase Functions
uses: docker://w9jds/firebase-action:master
with:
args: deploy --only functions:nextjs-server
env:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
PROJECT_PATH: firebase
- name: Deploy Firebase Hosting
uses: w9jds/firebase-action@master
with:
args: deploy --only hosting:storefront
env:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
PROJECT_PATH: firebase