Skip to content

fix(deps): update npm dependencies (minor) #3762

fix(deps): update npm dependencies (minor)

fix(deps): update npm dependencies (minor) #3762

# Run it locally with act
# 1. Install act:
# `brew install act`
# 2. Create a .secret file with the following content:
# `GITHUB_TOKEN=your_github_token`
# PULL REQUEST
# 1. Create a act_pull_request.json file in case of a pull request with the following content:
# `{"pull_request": {"number": <PR number>, "head": {"ref": "<PR branch name>", "sha": "PR commit sha"}, "base": {"ref": "main"}}, "repository": {"name": "juno", "owner": {"login": "cloudoperators"}}}`
# 2. Run the following command:
# `act pull_request --container-architecture linux/amd64 -P default=catthehacker/ubuntu:act-latest -e act_pull_request.json -W .github/workflows/deploy-pr-preview.yaml`
name: PR Preview Deployment 🚀
on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
paths:
- "packages/ui-components/**"
- "apps/example/**"
# Limit the concurrency of entire workflow
concurrency: deploy-pr-preview-${{ github.ref }}
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pull-requests: write
env:
DEPLOY_PATH: tmp
NODE_VERSION: "22.16.0"
PREVIEW_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pr-preview/pr-${{ github.event.pull_request.number }}
jobs:
run-detect-changes:
# skip if the PR is from a forked repository
if: github.event.pull_request.head.repo.full_name == github.repository
uses: ./.github/workflows/shared-detect-pkg-changes.yaml
with:
paths: "packages apps"
runs-on: ubuntu-latest
build-deploy:
# skip if the PR is from a forked repository
if: github.event.pull_request.head.repo.full_name == github.repository
needs: [run-detect-changes]
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- name: Precompile ENVs
if: github.event.action != 'closed'
id: compile-envs
run: |
# setup ENVs for each app to preview
echo "IS_STORYBOOK_CHANGED=${{ contains(needs.run-detect-changes.outputs.changes, 'ui-components') }}" >> $GITHUB_ENV
echo "IS_EXAMPLE_CHANGED=${{ contains(needs.run-detect-changes.outputs.changes, 'example') || contains(needs.run-detect-changes.outputs.changes, 'ui-components') }}" >> $GITHUB_ENV
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
if: github.event.action != 'closed'
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
if: github.event.action != 'closed'
run: |
npm install -g pnpm
pnpm install --frozen-lockfile
- name: Create a folder with all compiled apps and pkgs
if: github.event.action != 'closed'
run: |
mkdir -p ${{ env.DEPLOY_PATH }}
- name: Build STORYBOOK if changes detected
id: build-storybook
if: github.event.action != 'closed' && env.IS_STORYBOOK_CHANGED == 'true'
run: |
pnpm --filter @cloudoperators/juno-ui-components run build-storybook
cp -r ${{ env.PACKAGE_PATH }}/storybook-static ${{ env.DEPLOY_PATH }}/${{ env.TARGET_FOLDER }}
env:
PACKAGE_PATH: packages/ui-components
TARGET_FOLDER: storybook
continue-on-error: true
- name: Build EXAMPLE if changes detected
id: build-example
if: github.event.action != 'closed' && env.IS_EXAMPLE_CHANGED == 'true'
run: ./.github/scripts/build-vite-app.sh
env:
PACKAGE_PATH: apps/example
TARGET_FOLDER: example
continue-on-error: true
- name: Generate index.html for Deployed Apps
if: github.event.action != 'closed'
env:
STORYBOOK_OUTCOME: "${{ steps.build-storybook.outcome }}"
EXAMPLE_OUTCOME: "${{ steps.build-example.outcome }}"
run: |
echo "<!DOCTYPE html><head><title>PR Preview</title></head><html><body><h1>Deployed Packages for PR ${GITHUB_HEAD_REF}</h1><ul>" > ${{ env.DEPLOY_PATH }}/index.html
# components name should map to the IS_<component>_CHANGED
COMPONENTS=("storybook" "example")
for component in "${COMPONENTS[@]}"; do
CHANGED_VAR="IS_${component^^}_CHANGED" # Make it uppercase for the env var
CHANGED="${!CHANGED_VAR}" # Get the value of the environment variable
if [ "$CHANGED" = "true" ]; then
OUTCOME_VAR="${component^^}_OUTCOME" # Make it uppercase for the env var
echo "==OUTCOME_VAR=="
echo $OUTCOME_VAR
echo "==="
BUILD_OUTCOME="${!OUTCOME_VAR}" # Get the value of the environment variable
echo "==BUILD_OUTCOME=="
echo $BUILD_OUTCOME
echo "==="
if [ "$BUILD_OUTCOME" == "success" ]; then
echo "<li><a href='./${component}/index.html' target="_blank">${component^} <span style='color:green;'>✓ Success</span></a></li>" >> ${{ env.DEPLOY_PATH }}/index.html
else
echo "<li>${component^} <span style='color:red;'>✗ Failed</span></li>" >> ${{ env.DEPLOY_PATH }}/index.html
fi
fi
done
echo "</ul></body></html>" >> ${{ env.DEPLOY_PATH }}/index.html
- uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1
with:
source-dir: ${{ env.DEPLOY_PATH }}/
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
qr-code: false