Skip to content

feat(framework): Custom Illustrations Documentation & API Enhancement #425

feat(framework): Custom Illustrations Documentation & API Enhancement

feat(framework): Custom Illustrations Documentation & API Enhancement #425

name: Deploy Website Preview (Netlify)
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- 'packages/website/**'
- 'docs/**'
- '*.md'
- 'README.md'
- 'packages/base/src/**/*.css'
- 'packages/base/src/**/*.ts'
- 'packages/ai/src/**/*.css'
- 'packages/ai/src/**/*.ts'
- 'packages/compat/src/**/*.css'
- 'packages/compat/src/**/*.ts'
- 'packages/fiori/src/**/*.css'
- 'packages/fiori/src/**/*.ts'
- 'packages/main/src/**/*.css'
- 'packages/main/src/**/*.ts'
- '!**/*.spec.ts'
- '!**/*.test.ts'
- '!**/test/**'
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 22
cache: 'yarn'
- name: Install dependencies
run: |
export NODE_OPTIONS="--max_old_space_size=4096"
yarn install
- name: Update version.md for PR
run: |
mkdir -p packages/website/static
touch packages/website/static/version.md
echo "PR #${{ github.event.number }} - $(git log -1 --format='%h %s')" > packages/website/static/version.md
echo "Branch: ${{ github.head_ref }}" >> packages/website/static/version.md
echo "Commit: $(git rev-parse HEAD)" >> packages/website/static/version.md
- name: Build website
env:
DEPLOYMENT_TYPE: "netlify_preview"
DEPLOYMENT_NETLIFY_PREVIEW_BASE_URL: "https://pr-${{ github.event.number }}--ui5-webcomponents-preview.netlify.app"
PR_NUMBER: "${{ github.event.number }}"
run: |
yarn ci:deploy:preview
- name: Check PR status before deployment
id: final-pr-check
if: always()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
script: |
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
if (pr.state !== 'open') {
console.log(`PR #${pr.number} was closed during build, skipping deployment`);
core.setOutput('should_deploy', 'false');
return;
}
console.log(`PR #${pr.number} is still open, proceeding with deployment`);
core.setOutput('should_deploy', 'true');
- name: Config Netlify CORS
if: steps.final-pr-check.outputs.should_deploy == 'true'
run: |
cat > packages/website/build/netlify.toml << 'EOF'
[build]
publish = "."
# CORS headers for local-cdn resources
[[headers]]
for = "/local-cdn/*"
[headers.values]
Access-Control-Allow-Origin = "*"
Access-Control-Allow-Methods = "GET, HEAD, OPTIONS"
Access-Control-Allow-Headers = "Content-Type, Accept"
Access-Control-Max-Age = "86400"
Cache-Control = "public, max-age=31536000, immutable"
EOF
- name: Deploy to Netlify
if: steps.final-pr-check.outputs.should_deploy == 'true'
uses: nwtgck/[email protected]
with:
publish-dir: './packages/website/build'
production-deploy: false
github-token: ${{ secrets.UI5_WEBCOMP_BOT_GH_TOKEN }}
deploy-message: "Deploy preview for PR #${{ github.event.number }}"
alias: pr-${{ github.event.number }}
enable-pull-request-comment: true
enable-commit-comment: false
overwrites-pull-request-comment: true
github-deployment-environment: preview
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Skip deployment notification
if: steps.final-pr-check.outputs.should_deploy == 'false'
run: |
echo "::notice::Skipping deployment - PR #${{ github.event.number }} was closed during build"