Skip to content

Build and deploy Production #1790

Build and deploy Production

Build and deploy Production #1790

name: "Build and deploy Production"
on:
push:
branches:
- main
schedule:
- cron: "45 */12 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-production
cancel-in-progress: true
jobs:
build:
name: Build site
runs-on: ubuntu-latest
env:
RENV_PROFILE: "production"
RENV_CONFIG_SANDBOX_ENABLED: FALSE
hugobd: public
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Set env parameters
run: |
ver=$(cat .hugoversion)
echo "hugovr=$ver" >> $GITHUB_ENV
- name: Check if translation step is needed
id: i18n
run: |
total=$(yq 'keys | length' config/_default/languages.yaml)
disabled=$(yq '.disableLanguages // [] | length' config/production/hugo.yaml)
active=$((total - disabled))
echo "Active languages for production: $active"
if [ "$active" -gt 1 ]; then
echo "needed=true" >> $GITHUB_OUTPUT
else
echo "needed=false" >> $GITHUB_OUTPUT
fi
- name: Install cURL Headers
if: steps.i18n.outputs.needed == 'true'
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev
- name: Setup R
if: steps.i18n.outputs.needed == 'true'
uses: r-lib/actions/setup-r@v2
with:
r-version: "renv"
- name: Setup renv
if: steps.i18n.outputs.needed == 'true'
uses: r-lib/actions/setup-renv@v2
- name: Populate untranslated pages
if: steps.i18n.outputs.needed == 'true'
run: Rscript scripts/missing_translations.R production
- name: Site data - Clean folders
run: rm -r data/directory
- name: Site data - DIRECTORY - Get
uses: actions/checkout@v6
with:
repository: rladies/directory
ssh-key: ${{ secrets.ssh_directoryy_repo }}
path: tmpd/dir
- name: Site data - DIRECTORY - Move
run: |
cp -r tmpd/dir/data/json data/directory
cp -r tmpd/dir/data/img/* assets/directory
- name: Site data - clean cloned repos
run: rm -rf tmpd
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: ${{ env.hugovr }}
extended: true
- name: Build
run: |
hugo \
-e production \
-d ${{ env.hugobd }}
- name: Deploy production 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ${{ env.hugobd }}