-
Notifications
You must be signed in to change notification settings - Fork 1
121 lines (102 loc) · 3.09 KB
/
lint_build_publish.yaml
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
on:
push:
branches:
- '**'
paths-ignore:
- '**.md'
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
name: lint_build_publish
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Setup Node and pnpm-store cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Dump versions
run: |
echo "node: $(node -v)"
echo "npm: $(npm -v)"
echo "pnpm: $(pnpm -v)"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup script cache
uses: actions/cache@v3
with:
path: node_modules/.cache
key: script-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-run-id-${{ github.run_id }}
restore-keys: script-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-run-id-
- name: Run lint
run: pnpm lint
build:
name: Build
needs: lint
runs-on: ubuntu-latest
env:
VITE_GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- name: Setup Node and pnpm-store cache
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: ${{ env.BRANCH_NAME == 'main' && 'pnpm build:prod' || 'pnpm build:dev' }}
- name: Cache build
uses: actions/cache@v3
with:
path: dist
key: ${{ github.sha }}-${{ github.run_number }}
- name: Expose build report
uses: actions/upload-artifact@v3
with:
name: Build Stats
path: reports/build-stats.html
retention-days: ${{ env.BRANCH_NAME == 'main' && 30 || 7 }}
- name: Expose sourcemaps
if: ${{ env.BRANCH_NAME == 'main' }}
uses: actions/upload-artifact@v3
with:
name: Sourcemaps
path: |
dist/**/*.map
if-no-files-found: ignore
retention-days: 30
publish:
name: Publish
needs: build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
steps:
- uses: actions/checkout@v3
- name: Restore Build
uses: actions/cache@v3
with:
path: dist
key: ${{ github.sha }}-${{ github.run_number }}
- name: Publish to Cloudflare Pages
uses: cloudflare/pages-action@v1
id: cfp
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: navigo-app
directory: dist
- run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "Deployed to ${{ steps.cfp.outputs.environment }} environment" >> $GITHUB_STEP_SUMMARY