Merge pull request #256 from TokenScript/feature/socios-oauth2 #323
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v4 | |
- 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" | |
- 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 | |
# Only use github package registry for @tokenscript | |
echo "//npm.pkg.github.com/:_authToken=${GPR_KEY}" >> .npmrc | |
echo "@tokenscript:registry=https://npm.pkg.github.com" >> .npmrc | |
cat .npmrc | |
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 }} | |
GPR_KEY: ${{ secrets.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 |