Skip to content

Set robots meta tag content "noindex, nofollow" for gh-pages preview #73

Set robots meta tag content "noindex, nofollow" for gh-pages preview

Set robots meta tag content "noindex, nofollow" for gh-pages preview #73

name: Export static site for RiskProfiler.ca
on:
push:
branches:
- main
- master
tags:
- 'v*'
workflow_dispatch:
# 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 job
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
env:
DOCKER_BUILDKIT: 1
TZ: America/Vancouver
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
- name: Run "docker compose up" to export static site for RiskProfiler
run: |
set -x
export DOCKER_WP_UID_GID="$(id -u):$(id -g)"
export OPTIONS_GIT_DESCRIBE=$(git describe --long --tags)
docker compose up --abort-on-container-exit --exit-code-from wpcli
- name: Upload debug log artifact
uses: actions/upload-artifact@v4
with:
name: simply-static-debug-log
path: wp-app/site/assets/plugins/simply-static/debug.txt
- if: startsWith(github.ref, 'refs/tags/')
name: Create tarball and ZIP file of static site
run: |
rp_ver="${GITHUB_REF/refs\/tags\//}"
cd html_static
GZIP=-9v tar cvzf riskprofiler.ca-static-site-${rp_ver}.tar.gz riskprofiler
zip -9rv riskprofiler.ca-static-site-${rp_ver}.zip riskprofiler
- if: startsWith(github.ref, 'refs/tags/')
name: Upload tarball and ZIP file as release assets
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: 'html_static/*.tar.gz;html_static/*.zip'
tags: true
draft: false
- name: Discourage search engines from indexing this preview site
run: |
for i in $(grep -lr '^<meta name="robots"' html_static/riskprofiler); do
sed -i '/^<meta name="robots"/s/content="[^"]\+"/content="noindex, nofollow"/' $i
done
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: html_static/riskprofiler
# Deployment job
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write
id-token: write
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4