Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 54 additions & 30 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
name: Build and Deploy

# Builds the React samples browser and hands it to IgniteUI/igniteui-actions, which deploys it to
# S3 behind CloudFront: vnext to staging, master to production. A manual run ("Use workflow
# from") builds and deploys the branch it runs on; other branches build but do not deploy.

on:
push:
branches:
- vnext
- master
workflow_dispatch:
inputs:
branch:
description: 'Branch to build and deploy (e.g. vnext)'
required: true

permissions:
contents: read

env:
BRANCH_REF: ${{ github.event.inputs.branch && format('refs/heads/{0}', github.event.inputs.branch) || github.ref }}
# One run per branch at a time, so a branch's pushes deploy in order.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ env.BRANCH_REF }}
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v7
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24.x
cache: npm
Expand Down Expand Up @@ -63,35 +65,57 @@ jobs:
# No source maps in the deployed site.
NODE_ENV: production

- name: Package samples browser
# The deploy deletes from S3 whatever the build no longer has, so a broken build must not
# leave here. igniteui-actions checks it again before it uploads.
- name: Check the build produced the samples browser
run: |
cd dist
zip -qr "${{ github.workspace }}/react-demos.zip" ./
test -f dist/index.html || { echo "::error::dist/index.html is missing"; exit 1; }
grep -q '/react-demos/' dist/index.html || { echo "::error::dist is not built for /react-demos/"; exit 1; }
echo "$(find dist -name '*.html' | wc -l) pages, $(find dist -type f | wc -l) files"

- name: Upload the site
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: site-react-demos
path: dist
# igniteui-actions downloads it later, possibly after waiting for an earlier deploy.
retention-days: 7
if-no-files-found: error
include-hidden-files: true
# A re-run of this job finds the first attempt's artifact still on the run.
overwrite: true

- name: Publish pipeline artifact
uses: actions/upload-artifact@v7
# Only vnext (staging) and master (production) deploy. igniteui-actions checks this run
# again (repository, workflow, branch, commit) and decides the S3 folder from the app name.
- name: Get a token for igniteui-actions
if: github.ref == 'refs/heads/vnext' || github.ref == 'refs/heads/master'
id: app-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
name: react-demos-artifact
path: react-demos.zip
client-id: ${{ secrets.IGNITEUI_GITHUB_APP_CLIENT_ID }}
private-key: ${{ secrets.IGNITEUI_GITHUB_APP_PRIVATE_KEY }}
owner: IgniteUI
repositories: igniteui-actions
# A dispatch needs only this; without it the token gets every permission the App has.
permission-contents: write

- name: Trigger Deploy Workflow in IgniteUI Actions
uses: actions/github-script@v9
- name: Start the deploy in IgniteUI/igniteui-actions
if: github.ref == 'refs/heads/vnext' || github.ref == 'refs/heads/master'
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
APP: react-demos
with:
github-token: ${{ secrets.CLASSIC_PAT_GITHUB }}
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.repos.createDispatchEvent({
owner: 'IgniteUI',
repo: 'igniteui-actions',
event_type: 'igniteui-samples-cd',
event_type: 'igniteui-samples-s3-cd',
client_payload: {
calling_branch: "${{ env.BRANCH_REF }}",
repository: "${{ github.repository }}",
run_id: "${{ github.run_id }}",
artifact_name: "react-demos-artifact",
base_href: "react-demos",
submodule_dir: "react-demos",
ref: "${{ github.ref }}",
sha: "${{ github.sha }}",
branch: '${{ github.ref_name }}',
}
app: process.env.APP,
run_id: String(context.runId),
repository: context.repo.owner + '/' + context.repo.repo,
calling_branch: context.ref,
sha: context.sha,
},
});
5 changes: 2 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Branch from and target `vnext`, which deploys to staging. `master` deploys to pr
| `src/pages/samples/[...slug].astro` | Redirects old `/samples/<slug>` URLs |
| `astro.config.mjs` | Vite plugins the sample contract below depends on (their comments explain why), and legacy redirects |
| `scripts/`, `scripts/lib/` | Repo scripts and their data: `versions.js`, `templates.js`, `unpublished.json`, `skip-type-check.json` |
| `public/web.config` | IIS config, shipped at the root of the deployed site |
| `tests/smoke/` | Playwright smoke tests against the production build |

Build output is git-ignored and regenerated: `dist/`, `public/code-viewer/`, `public/ig-themes/`, `.astro/`. Don't edit or commit it.
Expand Down Expand Up @@ -75,8 +74,8 @@ BASE_PATH=/react-demos npm run test:smoke

## Deploy contract

[.github/workflows/build-and-deploy.yml](.github/workflows/build-and-deploy.yml) builds `dist/` with `BASE_PATH=/react-demos`, zips its contents into `react-demos.zip` (artifact `react-demos-artifact`), and triggers IgniteUI/igniteui-actions, which syncs the zip into the IIS site folder and deletes every file the zip doesn't contain. Keep these in every build:
[.github/workflows/build-and-deploy.yml](.github/workflows/build-and-deploy.yml) builds `dist/` with `BASE_PATH=/react-demos` and uploads it as the artifact `site-react-demos`. On `vnext` (staging) and `master` (production) it then dispatches `igniteui-samples-s3-cd` to IgniteUI/igniteui-actions, which uploads the build to S3 behind CloudFront and deletes every file the build no longer has. A CloudFront Function in igniteui-actions (`infra/cloudfront/samples-router.js`) does the routing. Keep these in every build:

- `web.config` at the root of `dist/`, from `public/web.config`. It serves Astro's `<path>/index.html` for extensionless URLs.
- Every page as `<path>/index.html`: the CloudFront Function serves it for the extensionless URL `<path>`.
- A page per published sample at `/<group>/<component>/<name>`, plus the redirects from `/samples/<slug>` and `/<group>/<component>-<name>`.
- `code-viewer/<group>/<component>/<name>.json` for every published sample, in the schema documented in `scripts/generate-code-viewer.js`. The docs code viewer and its StackBlitz export read these files.
50 changes: 0 additions & 50 deletions public/web.config

This file was deleted.