Add draft watermark to PR versions of site #15
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
# Workflow to build and deploy to GitHub Pages, with previews for PRs | |
# Based on https://github.com/daiyi/gh-pages-pr-previews | |
name: github pages | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
deploy: | |
runs-on: ubuntu-20.04 | |
env: | |
PR_PATH: pull/${{github.event.number}} | |
steps: | |
- name: Comment on PR | |
uses: hasura/[email protected] | |
if: github.ref != 'refs/heads/main' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "Starting deployment of preview ⏳..." | |
- name: Set domain | |
run: echo "DOMAIN=osep.elisa.tech" >> $GITHUB_ENV | |
- name: Set base URL for preview if PR | |
if: github.ref != 'refs/heads/main' | |
run: echo "BASE_URL=https://${{ env.DOMAIN }}/${{ env.PR_PATH}}/" >> $GITHUB_ENV | |
- name: Add draft message watermark to css if PR | |
if: github.ref != 'refs/heads/main' | |
- run: cat docs/stylesheets/draft.css >> docs/stylesheets/elisa.css | |
- name: Setup python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Checkout the triggering ref | |
uses: actions/checkout@v4 | |
- name: Build site | |
run: | | |
pip install -r docs/requirements.txt | |
mkdocs build | |
- name: Deploy if this is the `main` branch | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
cname: ${{ env.DOMAIN }} | |
- name: Deploy to PR preview | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.ref != 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./public | |
destination_dir: ${{ env.PR_PATH }} | |
keep_files: true | |
- name: Update comment | |
uses: hasura/[email protected] | |
if: github.ref != 'refs/heads/main' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
repository: ${{ github.repository }} | |
number: ${{ github.event.number }} | |
id: deploy-preview | |
message: "A preview of ${{ github.event.after }} is here:\n\n ✨ ${{ env.BASE_URL }}" |