-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (91 loc) · 3.29 KB
/
deploy.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
name: Build and deploy to Github Pages
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
concurrency: provision_concurrency_group-${{ github.event.pull_request.number || github.ref_name }}
env:
# This is used during the build step (vite.config.js) to determine the base URL.
# https://vitejs.dev/guide/static-deploy#github-pages
DEPLOY_PATH: ${{ github.ref_name == 'main' && '/' || format('/previews/pr-{0}/{1}...{2}', github.event.pull_request.number, github.event.pull_request.base.sha, github.event.pull_request.head.sha) }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
cache: 'npm'
- name: Build
run: |
npm ci
npm run build
- name: Upload build output
uses: actions/upload-artifact@v3
with:
name: build-output
path: ./dist
deploy_prod:
runs-on: ubuntu-latest
if: github.ref_name == 'main'
needs: [build]
concurrency: deploy_prod_concurrency_group
steps:
- uses: actions/checkout@v2
- name: Download build output
uses: actions/download-artifact@v3
with:
name: build-output
path: ./dist
- name: Set up mutex
uses: ben-z/[email protected]
with:
branch: mutex-gh-pages
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./dist
clean-exclude: previews/*
deploy_preview:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: [build]
# Specify write permissions explicitly to make dependabot PRs happy:
# https://github.com/dependabot/dependabot-core/issues/3253#issuecomment-940182533
# This is okay in this job because we don't execute any external code (e.g. npm export).
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- name: Download build output
uses: actions/download-artifact@v3
with:
name: build-output
path: ./dist
- name: Set up mutex
uses: ben-z/[email protected]
with:
branch: mutex-gh-pages
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy to Preview Environment
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ./dist
target-folder: '.${{ env.DEPLOY_PATH }}'
- name: Create comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
I'm deploying a preview of [${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}][compare].
It will be ready in about a minute. [You can view it here][preview].
[compare]: ${{ github.event.pull_request.head.repo.html_url }}/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}
[preview]: ${{ github.event.pull_request.head.repo.homepage }}${{ env.DEPLOY_PATH }}