Skip to content

trigger-workflow

trigger-workflow #35

name: Deploy Hugo to GitHub Pages
on:
workflow_dispatch: {}
repository_dispatch:
types: [trigger-workflow]
push:
branches:
- main
paths:
- "docs/**"
- "website/**"
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
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
# Default to bash
defaults:
run:
shell: bash
jobs:
build:
runs-on: [default]
env:
HUGO_VERSION: 0.128.0
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout greenhouse repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
path: greenhouse
submodules: true
fetch-depth: 0
- name: Checkout greenhouse-extensions repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository_owner}}/greenhouse-extensions
ref: ${{ github.event.client_payload.sha }}
path: greenhouse-extensions
submodules: true
fetch-depth: 0
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Custom steps
env:
GREENHOUSE_GIT_DIR: "${{ github.workspace }}/greenhouse"
GREENHOUSE_EXTENSIONS_GIT_DIR: "${{ github.workspace }}/greenhouse-extensions"
DESTINATION_DIR: "docs/reference/catalog"
run: |
cd $GREENHOUSE_GIT_DIR
mkdir -p ${DESTINATION_DIR}
echo "collecting PluginDefinition descriptions from ${GREENHOUSE_EXTENSIONS_GIT_DIR}"
all_files=$(git -C $GREENHOUSE_EXTENSIONS_GIT_DIR grep --recursive --files-with-matches -e "kind: PluginDefinition" -- '*plugindefinition.yaml')
for f in $all_files; do
d=$(dirname $f)
filename="${GREENHOUSE_EXTENSIONS_GIT_DIR}/${d}/README.md"
if [[ ! -f $filename ]]; then
continue
fi
echo "copying ${GREENHOUSE_EXTENSIONS_GIT_DIR}/${d}/README.md" "${DESTINATION_DIR}/${d}.md";
cp $filename "${DESTINATION_DIR}/${d}.md";
done
- name: Install Node.js dependencies
env:
GREENHOUSE_GIT_DIR: "${{ github.workspace }}/greenhouse"
run: cd ${{ env.GREENHOUSE_GIT_DIR }}/website && [[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true
- name: Build with Hugo
env:
GREENHOUSE_GIT_DIR: "${{ github.workspace }}/greenhouse"
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
cd $GREENHOUSE_GIT_DIR/website
hugo mod clean
hugo mod vendor
hugo \
--logLevel info \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./greenhouse/website/public/
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: [default]
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4