Skip to content

Render & Deploy sbalci.github.io Site #266

Render & Deploy sbalci.github.io Site

Render & Deploy sbalci.github.io Site #266

# copied from https://github.com/etiennebacher/personal_website_distill/blob/master/.github/workflows/main.yml
# https://github.com/rstudio/distill/issues/350
on:
push:
branches: master
workflow_dispatch:
schedule:
- cron: '5 20 * * 6'
name: Render & Deploy sbalci.github.io Site
jobs:
build:
runs-on: macOS-latest
steps:
# - uses: actions/checkout@v3
# with:
# submodules: none
# submodules: recursive
# - name: Configure sparse-checkout
# run: |
# cd cv-files
# git config core.sparsecheckout true
# echo '*' > .git/info/sparse-checkout
# echo '!.gitmodules' >> .git/info/sparse-checkout
# git read-tree -mu HEAD
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: false
# - name: Disable submodule initialization
# run: |
# git submodule deinit --all
# echo > .gitmodules
# - name: Update submodule reference
# run: |
# git submodule update --init --recursive --remote --checkout
- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-pandoc@v2
- name: Install dependencies
run: |
options(repos = "https://cran.r-project.org")
if (!requireNamespace("rmarkdown", quietly = TRUE)) install.packages("rmarkdown", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
if (!requireNamespace("markdown", quietly = TRUE)) install.packages("markdown", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
if (!requireNamespace("distill", quietly = TRUE)) install.packages("distill", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
if (!requireNamespace("pagedown", quietly = TRUE)) install.packages("pagedown", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
if (!requireNamespace("fs", quietly = TRUE)) install.packages("fs", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
shell: Rscript {0}
- name: Update Pages
run: |
if (dir.exists(paths = "./public")) { fs::dir_delete(path = "./public") }
if (dir.exists(paths = "./docs")) { fs::dir_delete(path = "./docs") }
source("./R-scripts/add_random_case.R")
source("./R-scripts/website.R")
shell: Rscript {0}
- name: Render Pages
run: |
# rmarkdown::render('./patoloji-ders-notlari/index.Rmd')
rmarkdown::render('./_posts/patolojide-bilisim/patolojide-bilisim.Rmd')
rmarkdown::render('./Serdar-Balci-MD-Pathologist-CV.Rmd')
shell: Rscript {0}
- name: Render Site
run: Rscript -e 'rmarkdown::render_site(encoding = "UTF-8")'
- name: Copy redirects
run: Rscript -e 'fs::file_copy("404.md", "docs/404.md")'
- name: "Remove 404.html"
run: Rscript -e 'fs::file_delete("docs/404.html")'
- name: Organise Pages
run: |
if (dir.exists(paths = "./docs/public")) { fs::dir_delete(path = "./docs/public") }
shell: Rscript {0}
- name: "copy docs to public"
run: Rscript -e 'if (dir.exists(paths = "./docs")) { fs::dir_copy(path = "./docs", new_path = "./public", overwrite = TRUE) }'
- name: Commit results
run: |
git add -A
git commit -m 'Rebuild site' || echo "No changes to commit"
git push origin || echo "No changes to commit"
- name: Push to GitLab
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git remote add gitlab "https://oauth2:${{ secrets.GITLAB_PASSWORD }}@gitlab.com/sbalci/sbalci.gitlab.io.git"
git fetch --unshallow
git push --force gitlab master:main --no-tags
# build-to-gitlab:
# needs: quarto-render-and-deploy
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - name: Mirror + trigger CI
# uses: SvanBoxel/gitlab-mirror-and-ci-action@master
# with:
# args: "https://gitlab.com/sbalci/sbalci.gitlab.io"
# env:
# GITLAB_HOSTNAME: "gitlab.com"
# GITLAB_USERNAME: "sbalci"
# GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} # // Generate here: https://gitlab.com/profile/personal_access_tokens
# GITLAB_PROJECT_ID: "47334509" # // https://gitlab.com/<namespace>/<repository>/edit
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # // https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret