Merge pull request #136 from LevelCapTech/copilot/add-progress-column… #16
This file contains hidden or 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: gh-pages-deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "src/**" | |
| - "example/**" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: gh-pages-deploy-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: npm | |
| - name: Install root dependencies | |
| run: npm ci | |
| - name: Build library | |
| run: npm run build | |
| - name: Install example dependencies | |
| run: | | |
| cd example | |
| # file: 依存を symlink として扱い React 二重読み込みを避けるために必要 | |
| npm ci --install-links | |
| - name: Build example | |
| run: | | |
| cd example | |
| npm run build | |
| - name: Validate build output | |
| run: | | |
| if [ ! -d example/build ] || [ -z "$(ls -A example/build)" ]; then | |
| echo "example/build is missing or empty." >&2 | |
| exit 1 | |
| fi | |
| - name: Deploy to gh-pages | |
| run: | | |
| cd "$GITHUB_WORKSPACE" | |
| git fetch origin gh-pages || true | |
| OUT="$RUNNER_TEMP/example-build" | |
| rm -rf "$OUT" | |
| mkdir -p "$OUT" | |
| # example/build は上の "Validate build output" ステップで検証済み | |
| cp -R example/build/. "$OUT/" | |
| if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then | |
| git checkout -B gh-pages origin/gh-pages | |
| else | |
| git checkout --orphan gh-pages | |
| fi | |
| # node_modules 等の無視ファイルも含めて掃除し、成果物混入を防ぐ | |
| git clean -fdx | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git rm -rf . || true | |
| cp -R "$OUT/". . | |
| touch .nojekyll | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to deploy." | |
| exit 0 | |
| fi | |
| git commit -m "Deploy example to GitHub Pages" | |
| git push origin gh-pages |