Migrating GetHub Pages Actions to the new version #34
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: Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- portfolio # <--- Trigger deployment on pushes to "portfolio" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.3.0' | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build # → this calls `vite build --mode production` (as defined in package.json) | |
- name: Upload dist as artifact | |
uses: actions/upload-artifact@v4 # <-- Not deprecated! | |
with: | |
name: pages-artifact # <-- A name for the artifact | |
path: ./dist # <-- The build output | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
pages: write # Required to deploy to GitHub Pages | |
id-token: write # Required for OIDC token usage | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: pages-artifact # <-- Must match the name used above | |
path: dist # <-- Download into a "dist" folder | |
- name: Deploy to GitHub Pages | |
uses: actions/deploy-pages@v1 # <-- Official GH Pages deployment action | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} |