Release Demo #101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Demo | |
# Job will only run on push to the main branch after the test job and release library job have passed | |
on: | |
workflow_run: | |
workflows: [ "Release Library" ] | |
types: [ completed ] | |
workflow_dispatch: | |
inputs: { } | |
permissions: | |
# contents: write # Required to publish to GitHub Pages branch | |
# packages: write # Required to publish to GitHub Pages branch | |
id-token: write # Required to publish to GitHub Pages | |
pages: write # Required to publish to GitHub Pages | |
concurrency: | |
group: 'pages' | |
cancel-in-progress: false | |
env: | |
ARTIFACT_NAME: "build-demo-artifact" | |
jobs: | |
build: | |
if: | | |
github.ref == 'refs/heads/main' && | |
github.event.repository.fork == false && | |
github.actor != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
environment: github-pages | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js - Version ${{ vars.NODE_VERSION }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ vars.NODE_VERSION }} | |
cache: 'yarn' | |
- name: Create cache directories | |
run: mkdir -p ~/.cache/yarn && mkdir -p ${{ github.workspace }}/.yarn | |
- name: Cache Yarn dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/yarn | |
${{ github.workspace }}/.yarn | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build demo | |
run: | | |
yarn gh-pages:build | |
yarn gh-pages:copy404 | |
yarn gh-pages:postBuild | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ vars.DEMO_PATH }} | |
if-no-files-found: error | |
release: | |
if: | | |
github.ref == 'refs/heads/main' && | |
github.event.repository.fork == false && | |
github.actor != 'dependabot[bot]' | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
environment: github-pages | |
needs: [ build ] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: ${{ vars.DEMO_PATH }} | |
# - name: Deploy to gh-pages branch | |
# uses: peaceiris/actions-gh-pages@v4 | |
# with: | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# publish_dir: ${{ vars.DEMO_PATH }} | |
# publish_branch: gh-pages | |
# force_orphan: true | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact to Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ${{ vars.DEMO_PATH }} | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |