Skip to content

Commit 2936463

Browse files
committed
ci(workflows): preview
- https://vercel.com/guides/how-can-i-use-github-actions-with-vercel Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 1db75bc commit 2936463

File tree

3 files changed

+66
-14
lines changed

3 files changed

+66
-14
lines changed

.github/workflows/preview.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Vercel Preview
2+
#
3+
# References:
4+
#
5+
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#pull_request
6+
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#push
7+
# - https://docs.github.com/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
8+
# - https://github.com/actions/checkout
9+
# - https://vercel.com/guides/how-can-i-use-github-actions-with-vercel
10+
11+
---
12+
name: preview
13+
on:
14+
pull_request:
15+
branches:
16+
- main
17+
push:
18+
branches:
19+
- feat/**
20+
- hotfix/**
21+
- main
22+
paths:
23+
- .vercelignore
24+
- docs/**
25+
- vercel.json
26+
workflow_dispatch:
27+
permissions:
28+
packages: read
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
HUSKY: 0
32+
REF: ${{ github.head_ref || github.ref_name }}
33+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
34+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
35+
concurrency:
36+
group: ${{ github.workflow }}-${{ github.ref }}
37+
cancel-in-progress: true
38+
jobs:
39+
preview:
40+
if: |
41+
github.actor != 'dependabot[bot]' && !startsWith(github.event.head_commit.message, 'release:')
42+
runs-on: ubuntu-latest
43+
environment: preview
44+
steps:
45+
- id: checkout
46+
name: Checkout ${{ env.REF }}
47+
uses: actions/checkout@v3.1.0
48+
with:
49+
ref: ${{ env.REF }}
50+
- id: install
51+
name: Install Vercel CLI
52+
run: npm install --global vercel@latest
53+
- id: env
54+
name: Pull environment
55+
run: vc pull --environment=preview --yes --token=${{ secrets.VERCEL_TOKEN }}
56+
- id: build
57+
name: Build docs
58+
run: vc build --token=${{ secrets.VERCEL_TOKEN }}
59+
- id: deploy
60+
name: Deploy docs preview
61+
run: vc deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}

docs/.vitepress/config.ts

+4-13
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,9 @@ const {
2727
ALGOLIA_API_KEY = '',
2828
HOSTNAME = '',
2929
NODE_ENV,
30-
VERCEL_ENV,
31-
VERCEL_URL = ''
30+
VERCEL_ENV
3231
} = process.env
3332

34-
/**
35-
* Site url.
36-
*
37-
* @const {string} SITE_URL
38-
*/
39-
const SITE_URL: string =
40-
VERCEL_ENV === 'preview' ? VERCEL_URL || HOSTNAME : HOSTNAME
41-
4233
/**
4334
* GitHub repository url.
4435
*
@@ -86,7 +77,7 @@ const config: UserConfig = defineConfig({
8677
*
8778
* @var {SitemapStream} stream
8879
*/
89-
let stream: SitemapStream = new SitemapStream({ hostname: SITE_URL })
80+
let stream: SitemapStream = new SitemapStream({ hostname: HOSTNAME })
9081

9182
/**
9283
* Sitemap routes.
@@ -191,9 +182,9 @@ const config: UserConfig = defineConfig({
191182
*/
192183
const url: string =
193184
pageData.relativePath === 'index.md'
194-
? SITE_URL
185+
? HOSTNAME
195186
: path
196-
.join(SITE_URL, pageData.relativePath)
187+
.join(HOSTNAME, pageData.relativePath)
197188
.replace(/\.md$/, '.html')
198189
.replace(/index\.html$/, '')
199190

vercel.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"devCommand": "vitepress dev docs",
66
"framework": "vite",
77
"ignoreCommand": null,
8-
"installCommand": null,
8+
"installCommand": "yarn --immutable",
99
"github": {
1010
"autoJobCancelation": true,
1111
"enabled": false,

0 commit comments

Comments
 (0)