Changed category to blog #473
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 Hugo site to GitHub Pages | |
name: Build and push site to gh-pages branch | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write | |
repository-projects: write | |
concurrency: | |
group: gh-pages | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive # Fetch the Docsy theme | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: '0.91.2' | |
extended: true | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
cache: 'npm' | |
# The action defaults to search for the dependency file (package-lock.json, | |
# npm-shrinkwrap.json or yarn.lock) in the repository root, and uses its | |
# hash as a part of the cache key. | |
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data | |
cache-dependency-path: '**/package-lock.json' | |
- name: Get PR metadata | |
uses: 8BitJonny/gh-get-current-pr@2.2.0 | |
if: github.event_name == 'pull_request' | |
with: | |
sha: ${{ github.event.pull_request.head.sha }} | |
id: PR | |
- run: npm ci | |
- run: git clone https://github.com/chipsalliance/tac themes/tac | |
- run: hugo --minify --baseURL https://chipsalliance.org | |
if: ${{ github.ref == 'refs/heads/main' }} | |
- run: hugo --minify --baseURL https://chipsalliance.org/preview/${{ steps.PR.outputs.number }}/ | |
if: github.event_name == 'pull_request' | |
- run: cp -a static public | |
- name: Download current release | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
path: ./current | |
- name: Preserve previews | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: | | |
mv ./current/preview/ ./public | |
- name: Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
if: ${{ github.ref == 'refs/heads/main' }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
cname: www.chipsalliance.org | |
# prepare metadata and upload artifacts for multi branch deployment | |
- name: Move deployment to the correct preview directory | |
if: github.event_name == 'pull_request' | |
run: | | |
mkdir preview/ | |
mv ./public preview/${{ steps.PR.outputs.number}} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
if: github.event_name == 'pull_request' | |
with: | |
name: pr_deployment | |
path: ./preview/ |