Skip to content

Check unique values of site_pop per site #1018

Check unique values of site_pop per site

Check unique values of site_pop per site #1018

Workflow file for this run

# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, prod]
pull_request:
branches: [main, prod]
release:
types: [published]
workflow_dispatch:
name: pkgdown
jobs:
build:
strategy:
matrix:
version:
- 'release'
- 'devel'
name: pkgdown site build (${{ matrix.version }})
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}-${{ matrix.version }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
id-token: write
pages: write
steps:
##########################################################################
# Identifying the latest and corresponding tag/sha to download
#########################################################################
- name: Check the repo to download
id: commit
run: |
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/CDCgov/ww-inference-model/releases/latest > \
latest_release
echo -n "This job is running on tag/sha: "
if [ "${{ matrix.version }}" = "release" ]; then
echo $(jq -r '.tag_name' latest_release)
echo "tag=$(jq -r '.tag_name' latest_release)" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.sha }}" >> $GITHUB_OUTPUT
echo ${{ github.sha }}
fi
- uses: actions/checkout@v4
with:
ref: ${{ steps.commit.outputs.tag }}
- name: Checkout the sha-associated repo
if: ${{ matrix.version == 'release' }}
uses: actions/checkout@v4
with:
sparse-checkout: './_pkgdown.yml'
path: pkgdown-${{ github.sha}}
- name: Overwriting the _pkgdown.yml
if: ${{ matrix.version == 'release' }}
run: |
cp pkgdown-${{ github.sha }}/_pkgdown.yml ./
rm -rf pkgdown-${{ github.sha }}
- name: Checking if the release is cached
if: ${{ matrix.version == 'release' }}
id: cache-hit
uses: actions/cache@v3
with:
key: pkgdown_site-${{ matrix.version }}-${{ steps.commit.outputs.tag }}-${{ hashFiles( './_pkgdown.yml' ) }}
path: './docs/'
# These steps only happen if the cache is not hit
- uses: r-lib/actions/setup-pandoc@v2
if: ${{ matrix.version != 'release' || steps.cache-hit.outputs.cache-hit != 'true' }}
with:
pandoc-version: "2.19.2"
- uses: r-lib/actions/setup-r@v2
if: ${{ matrix.version != 'release' || steps.cache-hit.outputs.cache-hit != 'true' }}
with:
r-version: "release"
use-public-rspm: true
install-r: false
extra-repositories: "https://mc-stan.org/r-packages/"
- uses: r-lib/actions/setup-r-dependencies@v2
if: ${{ matrix.version != 'release' || steps.cache-hit.outputs.cache-hit != 'true' }}
with:
pak-version: rc
extra-packages: any::pkgdown local::.
needs: website
- name: "Install cmdstan via cmdstanr"
uses: epinowcast/actions/install-cmdstan@v1
if: ${{ matrix.version != 'release' || steps.cache-hit.outputs.cache-hit != 'true' }}
with:
cmdstan-version: "latest"
- name: Build site
if: ${{ matrix.version != 'release' || steps.cache-hit.outputs.cache-hit != 'true' }}
run: |
# Changing the URL if it is a development build
if [ "${{ matrix.version }}" = "devel" ]; then
# Forcing the development mode
export PKGDOWN_DEV_MODE="devel"
else
# Setting the url
sed -i'' 's|url: https://cdcgov.github.io/ww-inference-model/|url: https://cdcgov.github.io/ww-inference-model/release/|' _pkgdown.yml
# Changing the navbar
sed -i'' 's|href: https://cdcgov.github.io/ww-inference-model/release|href: https://cdcgov.github.io/ww-inference-model/|' _pkgdown.yml
sed -i'' 's|text: (switch to release)|text: (switch to dev)|' _pkgdown.yml
sed -i'' 's|icon: fa-toggle-on|icon: fa-toggle-off|' _pkgdown.yml
# Forcing the release mode
export PKGDOWN_DEV_MODE="release"
fi
Rscript --vanilla -e \
"pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)"
if [ "${{ matrix.version }}" = "devel" ]; then
mv docs docs-tmp
mkdir docs
mv docs-tmp/dev/* docs
fi
- name: Upload artifact for GH pages deployment
id: upload-artifact
uses: actions/upload-artifact@v4
with:
path: "./docs/"
name: pkgdown-site-${{ matrix.version }}
combine:
outputs:
page_artifact_id: ${{ steps.upload-artifact.outputs.artifact_id }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Download dev artifact
uses: actions/download-artifact@v4
with:
name: pkgdown-site-devel
path: ./docs/
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: pkgdown-site-release
path: ./docs/release
- name: Upload pages artifact
id: upload-artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/
name: github-pages
retention-days: 7
deploy:
# check builds on PRs but only deploy when main changes
if: ${{ github.event_name != 'pull_request' }}
needs: combine
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub pages
uses: actions/deploy-pages@v4
post-page-artifact:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' }}
# This job depends on the `build` job
needs: combine
# Required permissions
permissions:
contents: read
pull-requests: write
steps:
# Post the artifact pulling the id from the `readme` step.
# The msg will refer to the arfitact as 'README file'.
- name: Post the artifact
uses: CDCgov/cfa-actions/[email protected]
with:
artifact-name: github-pages
gh-token: ${{ secrets.GITHUB_TOKEN }}