Skip to content

deploy

deploy #1083

Workflow file for this run

name: deploy
# Build and deploy the website
# Contains Tenzing's script to update the contributors list
# Contains a script to update the curated resources list
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '0 0 * * *' # Run daily at midnight
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: read
env:
HUGO_VERSION: "0.123.3"
HUGO_EXTENDED: true
PYTHON_VERSION: "3.11"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Hugo - Setup
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: ${{ env.HUGO_EXTENDED }}
- name: Python - Setup
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Cache - Pip Dependencies
id: pip-cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Python - Install dependencies
run: |
python3 -m pip install -r ./requirements.txt
- name: Python - Tenzing
run: |
python3 scripts/forrt_contribs/tenzing.py
- name: Python - Curated Resources
run: |
python3 content/resources/resource.py
- name: Script - Move Tenzing's output and validate
run: |
mv scripts/forrt_contribs/tenzing.md content/contributors/tenzing.md
if [ ! -f content/contributors/tenzing.md ]; then
echo "tenzing.md not found"
exit 1
fi
- name: Script - Validate curated resources
run: |
for file in content/curated_resources/*; do
if [ ! -f "$file" ]; then
echo "There is a non-markdown file ( $file ) in the curated resources folder. Exiting."
exit 1
fi
done
NUM_FILES=$(ls -1 content/curated_resources/*.md | wc -l)
echo "Number of curated resources: $NUM_FILES"
- name: Hugo - Build
run: |
if [ "$BRANCH" != 'refs/heads/master' ]; then
hugo --gc --minify --cleanDestinationDir --destination public --baseURL https://staging.forrt.org
else
hugo --gc --minify --cleanDestinationDir --destination public
fi
env:
BRANCH: ${{ github.ref }}
- name: Upload Artifact - Website
uses: actions/upload-artifact@v4
env:
ARTIFACT_NAME: forrt-website-${{ github.run_number }}
with:
name: ${{ env.ARTIFACT_NAME }}
path: public/
retention-days: 1
deploy-test:
name: Deploy - Test
runs-on: ubuntu-22.04
concurrency:
group: staging
permissions:
contents: write
needs: build
steps:
- name: Download Artifact - Website
uses: actions/download-artifact@v4
with:
name: forrt-website-${{ github.run_number }}
path: ${{ github.repository }}/forrt-website
- name: Deploy - GitHub Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e
with:
personal_token: ${{ secrets.STAGING_GITHUB_TOKEN }}
publish_dir: ${{ github.repository }}/forrt-website
external_repository: forrtproject/webpage-staging
publish_branch: staging
cname: staging.forrt.org
deploy-prod:
name: Deploy - Production
runs-on: ubuntu-22.04
permissions:
contents: write
needs:
- deploy-test
if: (github.event_name == 'push' || github.event_name == 'schedule') && github.ref == 'refs/heads/master' && github.event.repository.fork == false
steps:
- name: Download Arfifact - Website
uses: actions/download-artifact@v4
with:
name: forrt-website-${{ github.run_number }}
path: ${{ github.repository }}/forrt-website
- name: Deploy - GitHub Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ github.repository }}/forrt-website
publish_branch: gh-pages
cname: forrt.org