io-actions/.github/workflows/static.yml
2025-06-13 12:21:10 -04:00

99 lines
2.7 KiB
YAML

# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
# push:
# branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
list-branches:
runs-on: ubuntu-latest
outputs:
branches: ${{ steps.list-all-branches.outputs.result }}
steps:
- uses: actions/github-script@v7
id: list-all-branches
with:
script: |
const branches = await github.rest.repos.listBranches({
owner: context.repo.owner,
repo: context.repo.repo,
})
const branchNames = branches.data.map(branch => branch.name)
return branchNames
# fan out and build every branch, upload each as an artifact
build:
runs-on: ubuntu-latest
needs:
list-branches
strategy:
matrix:
branch: ${{ fromJSON( needs.list-branches.outputs.branches ) }}
steps:
# matrix against branch names
- name: What Branch?
run: echo "${{ matrix.branch }}"
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: Vite Build
env:
branchPrefix: ${{ matrix.branch != 'main' && matrix.branch || '' }}
run: |
npm ci
npm run build -- --base /blockly-tool/${branchPrefix}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
path: './dist'
name: ${{ matrix.branch }}
# reduce artifacts to a single deployment
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs:
build
steps:
- name: Merge Build Artifacts
uses: actions/download-artifact@v4
with:
path: './dist'
- name: Move main into primary spot and verify
run: |
mv dist/main/* dist
rm -rf dist/main
ls -la dist
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4