refactor: use actions/upload-pages-artifact #4
Workflow file for this run
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: Build Site | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Use Node.js 18.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: yarn | |
- name: node_modules CI Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/node_modules | |
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Next.js CI Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/yarn.lock') }}- | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile --prefer-offline | |
- name: Build Site | |
run: yarn build | |
env: | |
CDNJS_BASE_URL: https://cdnjs.baoshuo.ren/ajax/libs | |
- name: Upload Build Output to Artifacts | |
uses: actions/upload-pages-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/out/ | |
retention-days: 30 | |
deploy-gh-pages: | |
name: Deploy Site to GitHub Pages | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: [build] | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
with: | |
## Is this attempting to deploy a pull request as a GitHub Pages preview site? | |
## NOTE: This feature is only in alpha currently and is not available to the public! | |
preview: false # ${{ github.event_name != 'push' }} |