-
Notifications
You must be signed in to change notification settings - Fork 393
153 lines (151 loc) · 5.15 KB
/
build.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build
on:
pull_request: {}
push:
branches:
- main
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Read .nvmrc
run: echo "NVMRC=$(cat ./.nvmrc)" >> $GITHUB_OUTPUT
id: nvm
- name: Use Node + Yarn
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
- run: yarn install --frozen-lockfile
- name: Detect env block
id: env-block
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
uses: actions/github-script@v6
with:
script: |
const detectEnvBlock = require("./.github/workflows/builds/detect-env-block.js")
return await detectEnvBlock({ github, context })
- name: Dev build
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')
run: |
echo -e ${{ steps.env-block.outputs.result }} > .env
echo 'USE_ANALYTICS_SOURCE="BETA"' >> .env
yarn build
env:
ALCHEMY_KEY: ${{ secrets.DEV_ALCHEMY_API_KEY || 'oV1Rtjh61hGa97X2MTqMY9kEUcpxP-6K' }}
BLOCKNATIVE_API_KEY: ${{ secrets.DEV_BLOCKNATIVE_API_KEY || 'f60816ff-da02-463f-87a6-67a09c6d53fa' }}
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }}
COMMIT_SHA: ${{ github.sha }}
- name: Production build
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
run: |
echo 'USE_ANALYTICS_SOURCE="PROD"' >> .env
yarn build
env:
ALCHEMY_KEY: ${{ secrets.ALCHEMY_API_KEY }}
BLOCKNATIVE_API_KEY: ${{ secrets.BLOCKNATIVE_API_KEY }}
UNS_API_KEY: ${{ secrets.UNS_API_KEY }}
SIMPLE_HASH_API_KEY: ${{ secrets.SIMPLE_HASH_API_KEY }}
ZEROX_API_KEY: ${{ secrets.ZEROX_API_KEY }}
COMMIT_SHA: ${{ github.sha }}
POAP_API_KEY: ${{ secrets.POAP_API_KEY }}
DAYLIGHT_API_KEY: ${{ secrets.DAYLIGHT_API_KEY }}
- name: Upload build asset
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: actions/upload-artifact@v3
with:
name: extension-builds-${{ github.event.number || github.event.head_commit.id }}
path: dist/*.zip
- name: Create Release and Upload Artifacts
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*.zip
draft: true
generate_release_notes: true
prerelease: ${{ contains(github.ref, '-pre') || contains(github.ref, 'v0.') }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Read .nvmrc
run: echo "NVMRC=$(cat ./.nvmrc)" >> $GITHUB_OUTPUT
id: nvm
- name: Use Node + Yarn
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Read .nvmrc
run: echo "NVMRC=$(cat ./.nvmrc)" >> $GITHUB_OUTPUT
id: nvm
- name: Use Node + Yarn
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn lint
detect-if-flag-changed:
runs-on: ubuntu-latest
outputs:
path-filter: ${{ steps.filter.outputs.path-filter }}
steps:
- uses: actions/checkout@v3
if: github.event_name == 'pull_request'
- uses: dorny/paths-filter@v2
if: github.event_name == 'pull_request'
id: filter
with:
filters: |
path-filter:
- '.env.defaults'
e2e-tests:
if: |
github.ref == 'refs/heads/main'
|| contains(github.head_ref, 'e2e')
|| needs.detect-if-flag-changed.outputs.path-filter == 'true'
needs: [build, detect-if-flag-changed]
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Read .nvmrc
run: echo "NVMRC=$(cat ./.nvmrc)" >> $GITHUB_OUTPUT
id: nvm
- name: Use Node + Yarn
uses: actions/setup-node@v3
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
cache: "yarn"
- run: yarn install --frozen-lockfile
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- uses: actions/download-artifact@v3
with:
name: extension-builds-${{ github.event.number || github.event.head_commit.id }}
- name: Extract extension
run: unzip -o chrome.zip -d dist/chrome
- name: Run Playwright tests
run: xvfb-run npx playwright test
#env:
# DEBUG: pw:api*
- uses: actions/upload-artifact@v3
if: failure()
with:
name: debug-output
path: |
test-results/
#videos/
retention-days: 30