-
Notifications
You must be signed in to change notification settings - Fork 93
99 lines (95 loc) · 3.08 KB
/
test-and-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
name: Test and Build
on:
workflow_call:
inputs:
flow:
required: true
type: string
branch:
required: true
type: string
configuration:
required: true
type: string
# Define a concurrency group at the branch level for the current workflows.
# Triggered workflow will be queued and cancel the previous ones
concurrency:
group: pr-${{ github.ref }}
cancel-in-progress: true
jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache node modules
id: cache
uses: actions/cache@v2
with:
path: node_modules
key: cache-node-${{ hashFiles('pnpm-lock.yaml') }}
- name: Setup Node
uses: actions/setup-node@v1
if: steps.cache.outputs.cache-hit != 'true'
with:
node-version: 16
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
- name: pnpm install
run: pnpm install --no-frozen-lockfile
nx:
name: Nx Commands
runs-on: ubuntu-latest
needs: [install-deps]
strategy:
fail-fast: false
matrix:
target: [test, build]
steps:
- name: Checkout [${{ inputs.branch }}]
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Make envfile
uses: SpicyPizza/create-envfile@v1.3
with:
envkey_DB_USER: ${{ secrets.DB_USER }}
envkey_NEXT_PUBLIC_WEBSITE_URL: ${{ secrets.NEXT_PUBLIC_WEBSITE_URL }}
envkey_NEXT_PUBLIC_MATOMO_URL: ${{ secrets.NEXT_PUBLIC_MATOMO_URL }}
envkey_NEXT_PUBLIC_MATOMO_SITE_ID: ${{ secrets.NEXT_PUBLIC_MATOMO_SITE_ID }}
envkey_NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
envkey_NEXT_PUBLIC_SLUG_FOR_OFFICIAL_PREVIEW: ${{ secrets.NEXT_PUBLIC_SLUG_FOR_OFFICIAL_PREVIEW }}
file_name: .env.local
fail_on_empty: false
- name: show content of .env.local
run: cat .env.local
- uses: szenius/set-timezone@v1.0
name: Change timezone
with:
timezoneLinux: Europe/Paris
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
- name: Cache node modules
uses: actions/cache@v2
with:
path: node_modules
key: cache-node-${{ hashFiles('pnpm-lock.yaml') }}
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v2
with:
main-branch-name: ${{ inputs.branch }}
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Check if all previews exist
if: matrix.target != 'build'
run: pnpm ts-node scripts/preview-check.ts
- name: Nx Affected
run: pnpm nx affected --target=${{ matrix.target }} --parallel --max-parallel=3 --configuration=${{ inputs.configuration }}
- name: Next export
if: matrix.target == 'build'
run: pnpm nx run devchoices-next:export
- uses: actions/upload-artifact@master
if: matrix.target == 'build'
with:
name: dist
path: dist