Build iAdapter UI apps #17
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 --legacy-peer-deps | |
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 | |
echo "Zipped files created in builds directory:" | |
ls builds/ # List zipped files for debugging | |
working-directory: iadapter-applications | |
# Move zipped files to the .github/apps-builds folder | |
- name: Move zipped files to .github/apps-builds | |
run: | | |
mkdir -p .github/apps-builds # Create the target directory if it doesn't exist | |
if ls builds/*.zip 1> /dev/null 2>&1; then # Check if any zip files exist | |
mv builds/*.zip .github/apps-builds/ # Move all zip files to the target directory | |
else | |
echo "No zip files found in builds directory to move." | |
fi | |
working-directory: iadapter-applications | |
# Optional: Commit the zipped builds to the repository (if desired) | |
- name: Commit zipped builds to repository | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout develop # Switch to the develop branch or the appropriate branch | |
git add .github/apps-builds | |
git commit -m "Add zipped builds for apps: ${{ github.event.inputs.app_names }}" | |
git push origin develop |