Skip to content

feat: Add support to add msd codes in mappings #137

feat: Add support to add msd codes in mappings

feat: Add support to add msd codes in mappings #137

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,apps"
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]
env:
# Default list of apps to build for push and pull request events
DEFAULT_APP_NAMES: "login,client-management,dashboard,mapping-and-data-extraction,workflows-management"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- 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 }}-
- name: Install dependencies
run: npm install --legacy-peer-deps
working-directory: iadapter-applications
- name: Determine apps to build
id: determine-apps
run: |
# Use the app_names input if available, otherwise use the default value
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
app_names="${{ github.event.inputs.app_names }}"
else
app_names="${{ env.DEFAULT_APP_NAMES }}"
fi
echo "Apps to build: $app_names"
echo "app_names=$app_names" >> $GITHUB_ENV # Export as environment variable for future steps
- name: Build NX apps
run: |
# Get the comma-separated list of apps and convert to an array
echo "Raw app_names input: '${{ env.app_names }}'"
app_names="${{ env.app_names }}"
if [ -z "$app_names" ]; then
echo "The 'app_names' input is empty. Please provide a list of apps to build."
exit 1 # Exit with error status if the input is empty
fi
IFS=',' read -ra APPS <<< "$app_names"
if [ ${#APPS[@]} -eq 0 ]; then
echo "No apps specified to build. Exiting."
exit 1
fi
for app in "${APPS[@]}"; do
echo "Building $app in NX workspace..."
npx nx build "$app" --configuration production
done
if [ -d dist ]; then
echo "Successfully created 'dist' directory."
ls dist/
else
echo "Failed to create 'dist' directory."
fi
working-directory: iadapter-applications
- name: Zip build outputs
run: |
mkdir -p builds
if [ -d builds ]; then
echo "Successfully created 'builds' directory."
else
echo "Failed to create 'builds' directory."
fi
app_names="${{ env.app_names }}"
IFS=',' read -ra APPS <<< "$app_names"
for app in "${APPS[@]}"; do
build_dir="dist/apps/${app}/browser/"
zip_file="${app}.zip"
if [ -d "$build_dir" ]; then
cp -r dist/apps/${app}/browser builds/
cd builds || exit 1
mv browser "${app}"
ls
pwd
echo "Zipping $app build output..."
zip -r "$zip_file" "${app}"/*
cd ..
echo "Zipped $app build output to $zip_file"
pwd
else
echo "Build directory $build_dir not found, skipping zipping for $app."
fi
done
ls builds/ # List zipped files for debugging
working-directory: iadapter-applications
- name: Move zipped files to .github/apps-builds
run: |
mkdir -p .github/apps-builds
# Delete existing contents in .github/apps-builds to ensure a clean state
if [ -d ".github/apps-builds" ]; then
echo "Clearing existing contents in .github/apps-builds..."
rm -rf .github/apps-builds/*
ls -al .github/apps-builds/
fi
# Check if there are zip files in the builds directory
if ls iadapter-applications/builds/*.zip 1> /dev/null 2>&1; then
echo "Moving new zipped files to .github/apps-builds..."
mv iadapter-applications/builds/*.zip .github/apps-builds/
# List the contents of the .github/apps-builds directory for verification
echo "Moved zipped files to .github/apps-builds:"
ls -al .github/apps-builds/
else
echo "No zip files found in builds directory to move."
fi
- name: Commit zipped builds to repository
run: |
# Set up Git configuration for commit
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
# Checkout the branch to commit the changes
# ${{ github.ref_name }}
git branch -a
git checkout develop # Checkout to the current branch, replace with ${{ github.ref_name }} in future
# Add changes to the git index
git add .github/apps-builds
# Commit changes with a message
git commit -m "Update zipped builds for apps: ${{ env.app_names }}"
# Push the changes back to the repository
git push origin develop # Replace with ${{ github.ref_name }}