Deploy Next.js site to Pages #51
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
# Sample workflow for building and deploying a Next.js site to GitHub Pages | |
# | |
# To get started with Next.js see: https://nextjs.org/docs/getting-started | |
# | |
name: Deploy Next.js site to Pages | |
on: | |
# # Runs on pushes targeting the default branch | |
# push: | |
# branches: ["main"] | |
# # Runs on pull requests | |
# pull_request: | |
# 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: | |
# Permission to read the releases: draft releases are only available when using the write access token (confirmed with GitHub's support) | |
contents: write | |
# Permission to write to the pages service | |
pages: write | |
# TODO: Added automatically by the template workflow... | |
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: | |
deploy: | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
# A repository is needed to let GitHub's CLI figure out from where to download the releases | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download latest release | |
shell: bash | |
env: | |
# Necessary to allow the runner to access GitHub's APIs | |
GH_TOKEN: ${{ github.token }} | |
# Enables extra debug | |
# GH_DEBUG: api | |
run: | | |
LATEST_RELEASE=$(gh release list --limit 1 --json name --jq ".[0].name" | cat) | |
echo "Latest release: $LATEST_RELEASE" | |
gh release download $LATEST_RELEASE --pattern "good-morph-app-*.tar" --output "good-morph-app.tar" | |
- name: Upload latest release as an artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
# By convention the actions/deploy-pages@v4 action uses the github-pages artifact name. | |
name: github-pages | |
path: ./good-morph-app.tar | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |