forked from hashicorp/packer
-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (60 loc) · 2.44 KB
/
doc-ci-cd.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
# Copyright (c) Jiaqi Liu
name: Documentation CI/CD
'on':
pull_request:
push:
branches:
- master
jobs:
documentation-ci-cd:
name: Test & Release Documentation
runs-on: ubuntu-latest
defaults:
run:
working-directory: website
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18 # must be 18 or above to avoid "Cannot read properties of undefined (reading 'version')"
- name: Test documentation build
run: npm run build
continue-on-error: true # HC closed source tutorials page, we can't get it anyway
- name: Bundle up a GitHub Pages Deployable
# if: github.ref == 'refs/heads/master'
run: |
mkdir hashicorp-packer-docs
cp -r website-preview/.next/server/pages/* hashicorp-packer-docs
mkdir hashicorp-packer-docs/_next
cp -r website-preview/.next/static hashicorp-packer-docs/_next/static
# The next command is not allowed by shellcheck. https://www.linuxjournal.com/content/bash-extended-globbing
# IMMUTABLE_DEPLOY_ARTIFACT_ID=$(ls website-preview/.next/static/ | grep -Ev "chunks|images|css|media")
# So we replace it with "find" command below
# Reference:
# https://stackoverflow.com/a/6745470
# https://stackoverflow.com/a/13525005
# https://superuser.com/a/1016521
# https://stackoverflow.com/a/7715567
IMMUTABLE_DEPLOY_ARTIFACT_ID=$(
find website-preview/.next/static/ \
-not -name images \
-not -name chunks \
-not -name css \
-not -name media \
-mindepth 1 \
-maxdepth 1 \
-execdir echo {} ';'
)
mkdir -p hashicorp-packer-docs/_next/data/"${IMMUTABLE_DEPLOY_ARTIFACT_ID}"
cp -r website-preview/.next/server/pages/* hashicorp-packer-docs/_next/data/"${IMMUTABLE_DEPLOY_ARTIFACT_ID}"
cd hashicorp-packer-docs/
touch .nojekyll
echo "packer.qubitpi.org" >> CNAME
- name: Deploy to GitHub Pages
# if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: website/hashicorp-packer-docs
user_name: QubitPi
user_email: jack20220723@gmail.com