-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 1.42 KB
/
deploy.yml
File metadata and controls
60 lines (51 loc) · 1.42 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
name: Deploy to GitHub Pages
on:
push:
branches:
- master
- Local_writing
permissions:
contents: write
pages: write
id-token: write
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build site
run: |
if [ "${{ github.ref_name }}" == "master" ]; then
echo "Building for production (master)"
npm run build
DEPLOY_DIR="_site"
TARGET_DIR="."
else
echo "Building for preview (Local_writing)"
PATH_PREFIX=/preview npm run build
DEPLOY_DIR="_site"
TARGET_DIR="preview"
fi
echo "DEPLOY_DIR=$DEPLOY_DIR" >> $GITHUB_ENV
echo "TARGET_DIR=$TARGET_DIR" >> $GITHUB_ENV
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.DEPLOY_DIR }}
destination_dir: ${{ env.TARGET_DIR }}
keep_files: ${{ github.ref_name != 'master' }}
publish_branch: gh-pages