Update build-uid-apps.yml #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
name: Build iAdapter UI apps | |
on: | |
workflow_dispatch: | |
inputs: | |
app_names: | |
description: "Comma-separated list of app names to build within the NX workspace" | |
default: "login,client-management" | |
required: true | |
type: string | |
push: | |
branches: | |
- develop | |
pull_request: | |
branches: | |
- develop | |
jobs: | |
build-and-zip: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Use a specific Node.js version compatible with your NX workspace | |
node-version: [20.x] | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Set up Node.js environment | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
# Install NX globally | |
- name: Install NX globally | |
run: npm install -g [email protected] | |
- name: Cache Node modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
iadapter-applications/node_modules | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('iadapter-applications/package-lock.json', 'iadapter-applications/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}- | |
# Install NX workspace dependencies | |
- name: Install dependencies | |
run: npm install | |
working-directory: iadapter-applications | |
# Build the specified NX apps | |
- name: Build NX apps | |
run: | | |
# Get the comma-separated list of apps and convert to an array | |
app_names="${{ github.event.inputs.app_names }}" | |
IFS=',' read -ra APPS <<< "$app_names" | |
# Iterate through each app and build it using NX commands | |
for app in "${APPS[@]}"; do | |
echo "Building $app in NX workspace..." | |
npx nx build $app --configuration production | |
done | |
working-directory: iadapter-applications | |
# Zip the build output of each app | |
- name: Zip build outputs | |
run: | | |
# Create a directory to store zip files | |
mkdir -p builds | |
# Zip the build output of each app | |
for app in "${APPS[@]}"; do | |
build_dir="dist/apps/${app}" | |
zip_file="builds/${app}.zip" | |
if [ -d "$build_dir" ]; then | |
echo "Zipping $app build output..." | |
zip -r "$zip_file" "$build_dir" | |
else | |
echo "Build directory $build_dir not found, skipping zipping for $app." | |
fi | |
done | |
working-directory: iadapter-applications | |
# Upload the zipped build outputs as artifacts | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: nx-app-builds | |
path: iadapter-applications/builds |