Skip to content

Streamline CRA deps and webpack config #791

Streamline CRA deps and webpack config

Streamline CRA deps and webpack config #791

Workflow file for this run

name: web
permissions:
contents: write
on:
pull_request:
paths: [web/**]
types: [opened, synchronize, reopened, closed]
push:
paths: [web/**]
branches: [master]
workflow_dispatch:
jobs:
web:
if: github.repository == 'microsoft/windows-rs'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: current
- uses: actions/setup-node@v4
with:
node-version: '23.1' # Temporary: https://github.com/nodejs/node/issues/55826
- name: Build sites
shell: pwsh
run: |
cd current/web
$sites = Get-ChildItem -Directory
foreach ($site in $sites) {
Write-Host "Building $($site.Name)"
./build.ps1 $site.Name
}
- uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: Update gh-pages
shell: pwsh
run: |
cd gh-pages
$sites = Get-ChildItem ../current/web -Directory
foreach ($site in $sites) {
Write-Host "Deploying $($site.Name)"
if ("${{ github.event_name }}" -eq "pull_request") {
if ("${{ github.event.action }}" -eq "closed") {
Remove-Item -Recurse -Force -ErrorAction Ignore "$($site.Name)/preview/pr-${{ github.event.number }}"
} else {
if (Test-Path "$($site.FullName)/build") {
$previewPath = "$($site.Name)/preview/pr-${{ github.event.number }}"
New-Item -ItemType Directory -Force $previewPath | Out-Null
Remove-Item -Recurse -Force -ErrorAction Ignore "$previewPath/*"
Copy-Item "$($site.FullName)/build/*" $previewPath -Recurse -Force
}
}
} elseif ("${{ github.ref }}" -eq "refs/heads/master") {
if (Test-Path "$($site.FullName)/build") {
New-Item -ItemType Directory -Force $site.Name | Out-Null
Get-ChildItem "$($site.Name)/*" -Exclude "preview" | Remove-Item -Recurse -Force -ErrorAction Ignore
Copy-Item "$($site.FullName)/build/*" $site.Name -Recurse -Force
}
}
}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
$status = git status --porcelain
if ($status) {
git add .
git commit -m "Update from ${{ github.sha }}"
git push
}