Production Build #8
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 action will run. | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Set shared environment variables | |
env: | |
APP_VERSION: 2.12.1 | |
# 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: | |
VITE_ARCGIS_CLIENT_ID: ${{ secrets.VITE_ARCGIS_CLIENT_ID }} | |
# 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@v4 | |
with: | |
node-version: "22" | |
# Run back-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 --omit=dev | |
working-directory: app/server | |
# Run front-end processes (install, lint, test, bundle) | |
- 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: Install front-end dependencies | |
run: npm install --legacy-peer-deps | |
working-directory: app/client | |
- name: Build front-end files and move to server | |
run: | | |
VITE_ARCGIS_CLIENT_ID="$VITE_ARCGIS_CLIENT_ID" \ | |
npm run build | |
cd build | |
cp -r * ../../server/app/public | |
rm -rf * | |
working-directory: app/client | |
- name: Remove unnecessary server app files | |
run: rm -rf .env.example prettier.config.js nodemon.json app/config jest.config.js jest_setup.js tests | |
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: hmw_v${{ env.APP_VERSION }} | |
path: app/server |