-
-
Notifications
You must be signed in to change notification settings - Fork 73
119 lines (104 loc) · 3.24 KB
/
Copy pathpreview.yml
File metadata and controls
119 lines (104 loc) · 3.24 KB
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
name: Preview
on:
# pull-request means to deploy preview
# we need to access the environment secrets
pull_request_target:
permissions:
contents: read
jobs:
build-and-upload:
runs-on: ubuntu-latest
permissions:
contents: read
environment:
name: sandbox
env:
BASE_URL: '/'
steps:
# we set the correct repository and reference sha for PR preview
- name: Checkout PR
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
- name: Use Node.js
uses: actions/setup-node@v6
with:
cache: npm
check-latest: true
node-version: 22
node-version-file: '.nvmrc'
- name: Install Packages
run: npm ci --ignore-scripts
- name: Run Linting
run: npm run lint
- name: Setup Pages
uses: actions/configure-pages@v6
- name: Get latest Fastify tag
id: latest-fastify
uses: oprypin/find-latest-tag@dd2729fe78b0bb55523ae2b2a310c6773a652bd1 # v1.1.2
with:
repository: fastify/fastify
releases-only: true
- run: echo "Fastify is at version ${{ steps.latest-fastify.outputs.tag }}"
- name: Cache Fastify documentation
id: release-cache
uses: actions/cache@v5
with:
path: |
scripts/releases
scripts/releases.tag
key: ${{ steps.latest-fastify.outputs.tag }}-release-cache
# Here we need the token to download the `gh` archive
- name: Build website
run: npm run build:website
timeout-minutes: 30
env:
GH_TOKEN: ${{ github.token }}
SKIP_DOWNLOADS: ${{ steps.release-cache.outputs.cache-hit }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
path: './build'
deploy-to-staging:
needs:
- build-and-upload
concurrency:
group: ${{ github.ref_name }}-staging
cancel-in-progress: true
env:
BASE_URL: ''
permissions:
pull-requests: write
contents: write
environment:
name: staging
url: ${{ steps.deployment.outputs.NETLIFY_URL }}
outputs:
deployment_url: ${{ steps.deployment.outputs.NETLIFY_URL }}
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v7
with:
name: github-pages
path: website
- name: Extract artifact
run: tar -xvf artifact.tar
working-directory: website
shell: 'bash'
- name: Clean up before deploy
run: rm artifact.tar
working-directory: website
shell: 'bash'
- name: Display structure of downloaded files
run: ls -R
- name: Deploy to Netlify
uses: netlify/actions/cli@3185065f4ab2f6df6f2ef41ee013626e1c02a426 # master
id: deployment
with:
# https://cli.netlify.com/commands/deploy/
args: deploy --json --dir="./website" --message="Deploy from branch ${{ github.ref }}"
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}