-
Notifications
You must be signed in to change notification settings - Fork 23
55 lines (45 loc) · 1.68 KB
/
build-preview.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
# Zola build workflow.
# Setting it up:
# Adjust the variables below, under env.
#
# It is a general limitation of gh-actions that they cannot make the very first
# deploy to gh-pages. It will seem to work, but not appear on the CDN to be
# online. You need to go to settings and set the gh-pages branch, then future
# deploys will work. See
# https://github.com/marketplace/actions/github-pages-action#%EF%B8%8F-first-deployment-with-github_token
name: Build and deploy website preview
env:
ZOLA_VERSION: "0.18.0"
CNAME: "coderefinery.org"
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
# if this build is a PR build and the PR is NOT from a fork
if: github.event_name == 'pull_request' && github.repository == github.event.pull_request.head.repo.full_name
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install zola
run: |
set -x
wget -O - \
"https://github.com/getzola/zola/releases/download/v${ZOLA_VERSION}/zola-v${ZOLA_VERSION}-x86_64-unknown-linux-gnu.tar.gz" \
| sudo tar xzf - -C /usr/local/bin
- name: Generate HTML
run: zola build --base-url "https://${{ env.CNAME }}/previews/PR${{ github.event.number }}"
- name: Deploy website
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: ./public
TARGET_FOLDER: "previews/PR${{ github.event.number }}" # The website preview is going to be stored in the previews subfolder