Production Build #4
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
# This is a basic workflow to help you get started with Actions | |
name: Production Build | |
# Controls when the workflow will run | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Set default working directory for all jobs to /app | |
defaults: | |
run: | |
working-directory: ./app | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
build: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
environment: production | |
# Set environment variables | |
env: | |
APP_VERSION: 6.0.0 | |
CLOUD_SPACE: production | |
SERVER_BASE_PATH: /csb | |
FORMIO_BASE_URL: ${{ secrets.FORMIO_BASE_URL }} | |
FORMIO_PROJECT_NAME: ${{ secrets.FORMIO_PROJECT_NAME }} | |
FORMIO_PKG_AUTH_TOKEN: ${{ secrets.FORMIO_PKG_AUTH_TOKEN }} | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v4 | |
# Set up node and npm | |
- uses: actions/setup-node@master | |
# Run front-end processes (install, lint, test, bundle) | |
- name: Cache server app node modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/server/.npm | |
key: v1-npm-server-deps-${{ hashFiles('**/server/package-lock.json') }} | |
restore-keys: v1-npm-server-deps- | |
- name: Install server app dependencies | |
run: npm install | |
working-directory: app/server | |
- name: Cache client app node modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/client/.npm | |
key: v1-npm-client-deps-${{ hashFiles('**/client/package-lock.json') }} | |
restore-keys: v1-npm-client-deps- | |
- name: Add Formio private package repo auth token | |
run: echo "//pkg.form.io/:_authToken=${FORMIO_PKG_AUTH_TOKEN}" > .npmrc | |
working-directory: app/client | |
- name: Install client app dependencies | |
run: npm install | |
working-directory: app/client | |
- name: Build client app | |
run: | | |
VITE_SERVER_BASE_PATH="$SERVER_BASE_PATH" \ | |
VITE_CLOUD_SPACE="$CLOUD_SPACE" \ | |
VITE_FORMIO_BASE_URL="$FORMIO_BASE_URL" \ | |
VITE_FORMIO_PROJECT_NAME="$FORMIO_PROJECT_NAME" \ | |
npm run build | |
rm ../server/app/public/index.html | |
cd build | |
mv * ../../server/app/public | |
working-directory: app/client | |
- name: Remove unnecessary server app files | |
run: rm -rf .env.example .eslintrc.js .prettierrc.json | |
working-directory: app/server | |
- name: Copy production manifest file to server app | |
run: cp manifest-production.yml server/manifest-production.yml | |
working-directory: app | |
- name: Create production artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: csb-v${{ env.APP_VERSION }} | |
path: app/server |