Squashed commit of the following: #186
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: Client Build and Deploy Production | |
on: | |
push: | |
branches: [main] | |
paths: | |
- "client/**" | |
- ".github/workflows/client-prod.yaml" | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
tags: | |
description: 'Test scenario tags' | |
concurrency: | |
group: client-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
# Build specific env vars | |
CONFIG_API_URL: ${{ secrets.API_PROD_URL }} | |
VERCEL_DOMAIN: ${{ secrets.VERCEL_CLIENT_PROD_DOMAIN }} | |
# Global Vercel env vars | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CLIENT_PROJECT_ID }} | |
VERCEL_PROJECT_NAME: ${{ secrets.VERCEL_CLIENT_PROJECT_NAME }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Client Config | |
uses: actions/github-script@v4 | |
with: | |
script: | | |
const fs = require('fs') | |
fs.writeFileSync('./client/public/env.js', `window.env = { API_ENDPOINT: "${process.env.CONFIG_API_URL}" };`) | |
- name: Use Node.js 16.16 | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "16.16" | |
- name: npm 8.18 | |
run: npm install -g [email protected] | |
- name: vercel 27 | |
run: npm install -g [email protected] | |
- name: Client Deploy | |
run: | | |
TS="$( date +%s )" | |
npx vercel --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_SCOPE }} --force -m githubCommitSha=${{ github.sha }} -m timestamp=$TS | |
VERCEL_DEPLOYMENT_URL=$(npx vercel ls --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_SCOPE }} -m githubCommitSha=${{ github.sha }} -m timestamp=$TS 2>&1 | grep $VERCEL_PROJECT_NAME | awk {'print $2'}) | |
npx vercel alias --token ${{ secrets.VERCEL_TOKEN }} --scope ${{ secrets.VERCEL_SCOPE }} $VERCEL_DEPLOYMENT_URL $VERCEL_DOMAIN |