Files
starter-workflows/pages/nextjs.yml
T
Jess Bees 4a8f18e34d Add starter workflows for Pages builds and deployments (#1645)
* commit dummy workflow

* Update nextjs.yml

* renaming

* actually do a node build

* add jekyll build & deploy

* add permissions

* update jekyll to use composite upload action

* update next to use composite upload action

* update icon yml

* change nexjs icon

* Cleanup further the Jekyll template

* add gatsby starter workflow

* fix composite error

* fix updated actions

* Add Hugo

* Apply suggestions from code review

* Inital commit for nuxtjs starter workflow

* Cleanup all templates

* Add baseUrl through an action

* Use `base_url` output for Hugo configuration

* Create static.yml

* Create static.properties.json

* clarify path

* alternative jekyll icon with only tube

* use alternate jekyll icon

* use original xvg with proper viewBox parameters

* Add paper-spa/configure-pages to starter workflows

Replaces paper-spa/setup-pages where appropriate.

* use setup-ruby action instead of our container

* Add starter workflow for GitHub Pages's legacy Jekyll build

Named `jekyll-gh-pages` so that it connotes the familiar "hands off"
build process of the Jekyll build as performed by github pages workers,
without sounding deprecated by using the words "legacy" or "classic".

* Use the static_site_generator input so we can modify the correct config

* Update gatsby.yml

* Update wording on the 'legacy' jekyll workflow

* Fix filename: this should have a json extension

* Fix filename: this should have a .properties.json extension

* Update nextjs.properties.json

* Update static.properties.json

* Fix typo in name of Gatsby

* Remove pull_request triggers

* Update to latest versions of core Actions

* Remove '--if-present' flag from 'npm run build' commands to prevent silent failure

* Perform static HTML export for Next.js

* Add '--no-install' flag to 'npx' usage

* Update Nuxt starter workflow to run 'generate'

* Default to using npm if not using yarn

* Reword 'nuxt generate' step name

* Update pages/gatsby.yml

* Update description of Jekyll starter workflow

* Add configure-pages step to static workflow

* Add configuration step to enable Pages

* Pages: Set `PREFIX_PATHS` env var for Gatsby build

* Update Next.js starter workflow to cache builds

See https://nextjs.org/docs/advanced-features/ci-build-caching#github-actions

* Update NuxtJS starter workflow to cache builds

Basically modeled after the Gatsby starter workflow

* Call out node ssg getting started + setup

* Update nuxt documentation

* Retarget actions referencing `paper-spa` to `actions`

Also point to newly published `v1` tags rather than `main` or `v0`.

Co-authored-by: yimysty <yimysty@github.com>
Co-authored-by: Tommy Byrd <tcbyrd@github.com>
Co-authored-by: Yoann Chaudet <yoannchaudet@github.com>
Co-authored-by: Timothy <tjyung@github.com>
Co-authored-by: Smitha Borkar <12040799+smithaborkar@users.noreply.github.com>
Co-authored-by: James M. Greene <JamesMGreene@github.com>
2022-07-27 18:45:54 +05:30

96 lines
3.2 KiB
YAML

# 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: [$default-branch]
# 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:
contents: read
pages: write
id-token: write
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "::set-output name=manager::yarn"
echo "::set-output name=command::install"
echo "::set-output name=runner::yarn"
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "::set-output name=manager::npm"
echo "::set-output name=command::ci"
echo "::set-output name=runner::npx --no-install"
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Setup Pages
id: pages
uses: actions/configure-pages@v1
with:
# Automatically inject basePath in your Next.js configuration file and disable
# server side image optimization (https://nextjs.org/docs/api-reference/next/image#unoptimized).
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v3
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
- name: Static HTML export with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next export
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./out
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1