feat: Added React Demo webApp and deployment workflow #3
Workflow file for this run
This file contains hidden or 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: Deploy React WebApps | |
| on: | |
| pull_request: | |
| paths: | |
| - "examples/Web Applications/Framework Examples/**" | |
| - ".github/workflows/deploy.yml" | |
| push: | |
| branches: | |
| - "**" | |
| paths: | |
| - "examples/Web Applications/Framework Examples/**" | |
| - ".github/workflows/deploy.yml" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-package-deploy: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: # Add frameworks and Folder names here | |
| include: | |
| - framework: React | |
| app-folder: ApiKeyAuthApp | |
| # - framework: Angular | |
| # app-folder: my-angular-app-1 # example entry | |
| env: | |
| NODE_VERSION: "24.x.x" | |
| REACT_APPS_DIR: "examples/Web Applications/Framework Examples/React" | |
| ANGULAR_APPS_DIR: "examples/Web Applications/Framework Examples/Angular" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Set App Directory | |
| run: | | |
| if [ "${{ matrix.framework }}" == "React" ]; then | |
| echo "APP_DIR=${{ env.REACT_APPS_DIR }}/${{ matrix.app-folder }}" >> $GITHUB_ENV | |
| else | |
| echo "APP_DIR=${{ env.ANGULAR_APPS_DIR }}/${{ matrix.app-folder }}" >> $GITHUB_ENV | |
| fi | |
| - name: Install dependencies | |
| working-directory: ${{ env.APP_DIR }} | |
| run: npm ci | |
| - name: Lint | |
| working-directory: ${{ env.APP_DIR }} | |
| run: npm run lint | |
| - name: Build | |
| working-directory: ${{ env.APP_DIR }} | |
| run: npm run build | |
| - name: Setup Homebrew + Install slcli | |
| run: | | |
| eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | |
| brew tap ni-kismet/homebrew-ni | |
| brew install slcli | |
| echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH | |
| - name: Package into .nipkg | |
| working-directory: ${{ env.APP_DIR }} | |
| run: | | |
| WEBAPP_NAME=$(basename "$PWD") | |
| slcli webapp pack dist/ --output "${WEBAPP_NAME}.nipkg" | |
| echo "WEBAPP_NAME=${WEBAPP_NAME}" >> $GITHUB_ENV | |
| - name: Upload .nipkg artifact to gitHub | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.app-folder }}.nipkg | |
| path: ${{env.REACT_APPS_DIR}}/${{matrix.app-folder}}/${{env.WEBAPP_NAME}}.nipkg | |
| - name: Login to SystemLink | |
| run: | | |
| slcli login --profile ghActions --url "${{ secrets.SL_API_URL }}" --api-key "${{ secrets.SL_API_KEY }}" --web-url "${{ secrets.SL_WEBSITE_URL }}" --workspace "${{secrets.SL_WORKSPACE}}" | |
| - name: Deploy (publish new/update) webapp (nipkg) to NI internal SystemLink test tier | |
| working-directory: ${{ env.APP_DIR }} | |
| run: | | |
| pkg=${{env.WEBAPP_NAME}}.nipkg | |
| WEBAPP_NAME="$(basename "$pkg" .nipkg)_PROD" | |
| echo "**Deploying "$pkg" "$WEBAPP_NAME"**" | |
| WEBAPP_ID=$(slcli webapp list --workspace "${{ secrets.SL_WORKSPACE }}" --filter "$WEBAPP_NAME" --format json | jq -r '.[0].id // empty') | |
| if [[ -z "$WEBAPP_ID" ]]; then | |
| echo " *Webapp does not exist -- publishing new" | |
| slcli webapp publish "$pkg" --name "$WEBAPP_NAME" --workspace "${{ secrets.SL_WORKSPACE }}" | |
| else | |
| echo " *Webapp exists -- updating" | |
| slcli webapp publish "$pkg" --id "$WEBAPP_ID" | |
| fi | |
| echo "**Deployed "$WEBAPP_NAME"**" |