-
Notifications
You must be signed in to change notification settings - Fork 11
138 lines (114 loc) · 3.83 KB
/
preview.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
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
name: preview
on:
pull_request:
paths-ignore:
- 'firebase/**'
branches:
- 'main'
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache node_modules
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ matrix.os }}-node-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
- name: Install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: yarn --check-files --frozen-lockfile --non-interactive
build:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore node_modules
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ matrix.os }}-node-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
- name: Generate credential
run: echo $ENV_FILE > .analytics.credential.json
env:
ENV_FILE: ${{ secrets.GOOGLE_ANALYTICS_API_CREDENTIAL }}
- name: Set env
run: echo "GOOGLE_APPLICATION_CREDENTIALS=$(readlink -f .analytics.credential.json)" >> $GITHUB_ENV
- name: Build
run: yarn build
env:
GATSBY_ALGOLIA_APP_ID: ${{ secrets.GATSBY_ALGOLIA_APP_ID }}
GATSBY_ALGOLIA_SEARCH_KEY: ${{ secrets.GATSBY_ALGOLIA_SEARCH_KEY }}
ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY }}
GATSBY_GITHUB_API: ${{ secrets.GATSBY_GITHUB_API }}
RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }}
NODE_ENV: production
- uses: actions/upload-artifact@v2
with:
name: dist
path: public
unit-test:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore node_modules
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ matrix.os }}-node-${{ hashFiles(format('{0}{1}', github.workspace, '/yarn.lock')) }}
- name: Unit test
run: yarn test
deploy:
needs: [unit-test, build]
runs-on: ubuntu-latest
outputs:
details_url: ${{ steps.firebase.outputs.details_url }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: dist
path: public
- uses: FirebaseExtended/action-hosting-deploy@v0
id: firebase
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_BLOROGUE }}'
expires: 1d
projectId: blorogue
target: blog
performance:
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Make directory
run: mkdir lighthouse
- name: Run Lighthouse
id: lighthouse
uses: foo-software/lighthouse-check-action@master
with:
accessToken: ${{ secrets.GITHUB_TOKEN }}
locale: ja
urls: '${{ needs.deploy.outputs.details_url }},${{ needs.deploy.outputs.details_url }}/posts/,${{ needs.deploy.outputs.details_url }}/posts/vite-vue3-typescript/'
outputDirectory: lighthouse
prCommentEnabled: true
prCommentSaveOld: true
- uses: actions/upload-artifact@v2
with:
name: lighthouse
path: lighthouse
- name: Lighthouse Result check
uses: foo-software/lighthouse-check-status-action@master
with:
lighthouseCheckResults: ${{ steps.lighthouse.outputs.lighthouseCheckResults }}
minAccessibilityScore: '85'
minBestPracticesScore: '90'
minProgressiveWebAppScore: '90'