From 892bc1de2dc6cb6820d92da4eb77a4d621bd18e3 Mon Sep 17 00:00:00 2001 From: Eric Nantz Date: Wed, 3 Jan 2024 03:30:37 +0000 Subject: [PATCH] add dashboard deploy action --- .github/.gitignore | 1 + .github/workflows/build-dash.yaml | 71 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/build-dash.yaml diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/build-dash.yaml b/.github/workflows/build-dash.yaml new file mode 100644 index 0000000..5a60d46 --- /dev/null +++ b/.github/workflows/build-dash.yaml @@ -0,0 +1,71 @@ +on: + push: + branches: + - main + paths: + - '**.qmd' + - '**.R' + workflow_dispatch: + +name: build-dash + +permissions: + contents: write + +jobs: + build-dash: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + RENV_PATHS_ROOT: ~/.local/share/renv + steps: + + - uses: actions/checkout@v3 + + - name: Set up Quarto + uses: quarto-dev/quarto-actions/setup@v2 + with: + version: pre-release + + - uses: r-lib/actions/setup-r@v2 + + - name: Add Ubuntu dependencies + run: sudo apt-get install libglpk40 + + - uses: r-lib/actions/setup-renv@v2 + + - name: Cache targets data + uses: actions/cache@v3 + with: + path: _targets + key: ${{ runner.os }}-targets-v1-${{ hashFiles('**/cache.log') }} + restore-keys: | + ${{ runner.os }}-targets-v1- + + - name: Build Pipeline and Dashboard + run: Rscript -e 'targets::tar_make()' + + - name: Was the dashboard updated? + id: dashboard-updated + run: | + if [[ $(git status --porcelain -- index.html index_files/) ]]; then + echo "has_update=true" >> "$GITHUB_OUTPUT" + fi + + - name: Push Built Dashboard + if: steps.dashboard-updated.outputs.has_update == 'true' + run: | + git config --global user.name 'gha update bot' + git config --global user.email 'rpodcast@users.noreply.github.com' + git add --all + git commit --allow-empty -m "[auto] Build Dashboard $(TZ=America/New_York date +'%Y-%m-%d %H:%M')" + git push + + - name: Render and Publish to GH Pages + if: steps.dashboard-updated.outputs.has_update == 'true' + uses: quarto-dev/quarto-actions/publish@v2 + with: + target: gh-pages + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +