Test removing course #155
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Render to HTML & Deploy | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- src/G*/* | |
jobs: | |
check-changes: | |
name: Check if Rmd or image files changed | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Find directories with changed rmd or image files | |
id: changed-files-dir-names | |
uses: tj-actions/changed-files@v44 | |
with: | |
files: | | |
src/G*/*.{rmd,Rmd} | |
src/G*/img/*.{png,gif} | |
src/G*/img/*/*.{png,gif} | |
dir_names: "true" | |
dir_names_max_depth: 2 | |
dir_names_deleted_files_include_only_deleted_dirs: "true" | |
- name: Render modified courses to HTML and move output to docs | |
env: | |
WORKFLOW: true | |
CHANGED_DIRS: ${{ steps.changed-files-dir-names.outputs.all_changed_files }} | |
run: | | |
set -e | |
for folder in ${CHANGED_DIRS}; do | |
code="${folder#src/}" | |
./render.sh $code | |
done | |
if [ ! -d "docs" ]; then | |
mkdir docs | |
fi | |
cp ./assets/favicon.ico ./docs/favicon.ico | |
cp ./assets/index.html ./docs/index.html | |
- name: Add, Commit & Push | |
env: | |
CHANGED_DIRS: ${{ steps.changed-files-dir-names.outputs.all_changed_files }} | |
DELETED_DIRS: ${{ steps.changed-files-dir-names.outputs.deleted_files }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -e | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout --orphan temp-pages | |
git rm -r --cached . | |
git checkout remotes/origin/pages -- ./G* | |
for folder in ${CHANGED_DIRS} ${DELETED_DIRS}; do | |
code="${folder#src/}" | |
rm -rf $code | |
done | |
git add G* | |
git add docs | |
git clean -df | |
mv docs/* . | |
rm -r docs | |
git add . | |
git commit -m "Automatic: Render docs from ${GITHUB_SHA}" | |
git branch -M temp-pages pages | |
git push --force origin pages | |