SPFx as spyware - updates #2889
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
###################################################################### | |
# Build & deploy (if on `main`) the site to GitHub pages. | |
# Notes: | |
# - Images & CSS generated by Hugo's build processing are cached | |
# between runs (located in ./resources) | |
# - Caches auto-expire at the first workflow run each month | |
###################################################################### | |
name: Production build and deploy | |
defaults: | |
run: | |
shell: bash | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 0 * * *" | |
# 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 | |
env: | |
HUGO_VERSION: 0.104.3 | |
jobs: | |
###################################################################### | |
# build site | |
###################################################################### | |
build: | |
name: Build Hugo site | |
runs-on: ubuntu-latest | |
steps: | |
###################################################################### | |
# Setup GH Pages (primarily to get settings for Hugo build) | |
###################################################################### | |
- name: ⚙️ Setup (& acquire) GitHub Pages config | |
id: gh_pages | |
if: github.repository == 'pnp/blog' | |
uses: actions/configure-pages@v2 | |
###################################################################### | |
# download & install hugo | |
###################################################################### | |
- name: ⬇️⚙️ Download & install Hugo CLI (extended) | |
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 | |
env: | |
HUGO_VERSION: ${{ env.HUGO_VERSION }} | |
###################################################################### | |
# checkout codebase | |
###################################################################### | |
- name: Checkout repo codebase | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
clean: true | |
submodules: recursive | |
###################################################################### | |
# restore cached Hugo CSS & image processing results | |
###################################################################### | |
- name: 🔖 Generate cachekey for Hugo generated resources | |
id: hugo_cache_key | |
run: echo "VALUE=hugo-resources-$(date +'%Y%m')" >> $GITHUB_OUTPUT | |
- name: ♻️ Restore cached Hugo resources (generated images, styles, etc) | |
uses: actions/cache@v3 | |
with: | |
path: resources | |
key: ${{ steps.hugo_cache_key.outputs.VALUE }} | |
###################################################################### | |
# build site using Hugo CLI | |
###################################################################### | |
- name: 🏗 Build site with Hugo CLI | |
run: hugo --baseUrl "${SITE_BASE_URL}" --minify | |
env: | |
HUGO_ENVIRONMENT: production | |
HUGO_ENV: production | |
SITE_BASE_URL: "${{ steps.gh_pages.outputs.base_url }}/" | |
###################################################################### | |
# save built site artifacts for deployment to GitHub pages | |
###################################################################### | |
- name: 💾 Save site generated artifacts for deployment | |
uses: actions/upload-pages-artifact@v1 | |
if: (github.ref == 'refs/heads/main') && github.repository == 'pnp/blog' | |
with: | |
path: ./public | |
###################################################################### | |
# deploy site | |
###################################################################### | |
deploy: | |
name: Deploy site Hugo site | |
if: (github.ref == 'refs/heads/main') && github.repository == 'pnp/blog' | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
###################################################################### | |
# deploy Hugo site > GitHub Pages | |
###################################################################### | |
- name: 🚀 Deploy build to site | |
id: deployment | |
uses: actions/deploy-pages@v1 |