-
Notifications
You must be signed in to change notification settings - Fork 13
91 lines (76 loc) · 2.51 KB
/
deploy-to-gh-pages.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
name: Build & Deploy Examples To Staging
#description: Deploys examples to Github pages staging environment
on:
workflow_dispatch:
inputs:
negotiatorBranch:
description: "Use a specific branch from token-negotiator repo"
required: false
default: "none"
type: choice
options:
- "none"
- staging
- main
- patch
push:
branches:
- staging
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "**/package-lock.json"
registry-url: 'https://npm.pkg.github.com'
- name: Build
run: |
npm install
if [[ "${GITHUB_EVENT_NAME}" = push ]]; then
NEGOTIATOR_BRANCH="${GITHUB_REF_NAME}"
fi
if [[ ! -z $NEGOTIATOR_BRANCH && $NEGOTIATOR_BRANCH != "none" ]]; then
echo "Negotiator branch $NEGOTIATOR_BRANCH requested, updating package.json files"
scripts/use_negotiator_branch.js $NEGOTIATOR_BRANCH
fi
export BASE_PATH=/token-negotiator-examples/ecommerce-store-website
export MAX_PROCESSES=5
npm run install-examples
npm run clean
npm run build
npm run copy-artifacts
short_sha="${GITHUB_SHA:0:7}"
build_version="${GITHUB_REF_NAME}-${short_sha}"
build_time="$(date --utc --iso-8601=seconds)"
find build/ -name index.html -print0 |\
xargs -0 -r \
sed -i "s/<head>/<head><meta name=\"build-version\" content=\"${build_version}\"><meta name=\"build-time\" content=\"${build_time}\">/"
env:
NEGOTIATOR_BRANCH: ${{ inputs.negotiatorBranch }}
NODE_AUTH_TOKEN: ${{ github.token }}
- uses: actions/upload-artifact@v3
with:
name: build
path: build
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: build
path: build
- name: Push artifacts to GH pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build