generated from jhudsl/OTTR_Template_Website
-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (62 loc) · 2.11 KB
/
refresh-site.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# It was adapted by Candace Savonen for the OTTR_template https://github.com/jhudsl/OTTR_Template.
# This code was adapted by Carrie Wright to enable automated rendering of the site associated with this repository
name: Refresh Site
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- data/*
- '**.Rmd'
- styles.css
- _site.yml
- subdir_html/*.Rmd
- resources/images/*.png
- resources/images/favicon.ico
- site_libs/*
jobs:
yaml-check:
name: Load user automation choices
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.METRICMINER_GITHUB_PAT }}
- name: Load environment from YAML
uses: doughepi/[email protected]
with:
files: _config_automation.yml # Pass a space-separated list of configuration files. Rightmost files take precedence.
outputs:
rendering_docker_image: "${{ env.RENDERING_DOCKER_IMAGE }}"
render-main:
needs: yaml-check
runs-on: ubuntu-latest
container:
image: ${{needs.yaml-check.outputs.rendering_docker_image}}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.METRICMINER_GITHUB_PAT }}
- name: Delete old *.html
run: Rscript -e "rmarkdown::clean_site(preview = FALSE)"
- name: Run render html
id: site
run: Rscript -e "rmarkdown::render_site()"
- name: Check on render steps
if: steps.site.outcome != 'success'
run: |
echo site status ${{steps.site.outcome}}
exit 1
- name: Commit rendered site files
run: |
git config --system --add safe.directory $GITHUB_WORKSPACE
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add --force *.html
git add --force site_libs/*
git commit -m 'Render site' || echo "No changes to commit"
git push origin main || echo "No changes to push"