Skip to content

Workflow file for this run

name: Lecture Notes Quarto Render Bilingual Book Push Other Repos and GitLab
on:
workflow_dispatch:
push:
jobs:
lecture-notes:
if: "contains(github.event.head_commit.message, 'lecture') && !contains(github.event.head_commit.message, 'merge') && !contains(github.event.head_commit.message, 'WIP')"
runs-on: ubuntu-latest
continue-on-error: true
env:
RENV_PATHS_ROOT: ~/.local/share/renv
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "actions checkout"
uses: actions/checkout@v3
- name: "Setup pandoc"
uses: r-lib/actions/setup-pandoc@v2
- name: "Setup Quarto"
uses: quarto-dev/quarto-actions/setup@v2
- name: "Install curl for Bioconductor"
run: |
sudo apt -y install libcurl4-openssl-dev
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Setup renv
uses: r-lib/actions/setup-renv@v2
- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
tinytex: true
- uses: r-lib/actions/setup-tinytex@v2
- run: tlmgr --version
- name: Install additional LaTeX packages
run: |
tlmgr install titlesec
tlmgr install svg
tlmgr install transparent
tlmgr install tikzfill
tlmgr install sidenotes
tlmgr install marginnote
tlmgr install changepage
tlmgr list --only-installed
- name: Restore R package cache
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install R dependencies
run: |
if (!requireNamespace("remotes", quietly = TRUE)) {install.packages("remotes", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
remotes::install_deps(dependencies = TRUE)
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
renv::restore()
if (!requireNamespace("fs", quietly = TRUE)) install.packages("fs", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
if (!requireNamespace("quarto", quietly = TRUE)) install.packages("quarto", dependencies = TRUE, quiet = TRUE, verbose = FALSE)
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: "Render lecture-notes"
shell: Rscript {0}
run: |
# filestorender <- list.files(path = "./lecture-notes", pattern = ".qmd", full.names = TRUE, recursive = TRUE)
# purrr::map(.x = filestorender, .f= quarto::quarto_render, output_format = 'gfm')
# purrr::map(.x = filestorender, .f= quarto::quarto_render, output_format = 'revealjs')
# purrr::map(.x = filestorender, .f= quarto::quarto_render, output_format = 'all')
quarto::quarto_render(input = "./lecture-notes/*.qmd", as_job = FALSE, quiet = TRUE)
# quarto::quarto_render(input = filestorender, output_format = 'gfm', as_job = FALSE, quiet = TRUE)
# quarto::quarto_render(input = filestorender, output_format = 'revealjs', as_job = FALSE, quiet = TRUE)
# quarto::quarto_render(input = filestorender, output_format = 'all', as_job = FALSE)
- name: "Prepare lecture-notes readme"
shell: Rscript {0}
run: |
md_files <- list.files(path = './lecture-notes/', pattern = '*\\.md', full.names = FALSE, recursive = TRUE)
md_files <- md_files[!grepl(pattern = 'README', x = md_files)]
md_files <- gsub(pattern = '\\.md', replacement = '', x = md_files)
md_files_list <- purrr::map(.x = md_files, .f = ~ paste0('[', .x , '](./', .x , '.md)\n'))
readme_text <- paste0(unlist(md_files_list), collapse = "\n\n")
timestamp_text <- as.character(Sys.time())
readme_text <- paste0('# Patoloji Ders Notları \n\n', timestamp_text, '\n\n', readme_text)
if (file.exists('./lecture-notes/README.md')){fs::file_delete(path = './lecture-notes/README.md')}
writeLines(text = readme_text, con = './lecture-notes/README.md')
# - name: "Prepare patoloji-ders-notlari"
# shell: Rscript {0}
# run: |
# # if (dir.exists(paths = "./lecture-notes")) { fs::dir_copy(path = "./lecture-notes", new_path = "./ders-notlari", overwrite = TRUE) }
# # filestorender2 <- list.files(path = "./ders-notlari", pattern = ".qmd", full.names = TRUE, recursive = TRUE)
# # quarto::quarto_render(input = filestorender2, output_format = 'revealjs', as_job = FALSE, quiet = TRUE)
# # md_files2 <- list.files(path = './lecture-notes', pattern = '\\.md', full.names = TRUE)
# # fs::file_copy(path = md_files2, new_path = "./ders-notlari/", overwrite = TRUE)
- name: Commit results to main branch
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add .
git commit -m "CI added changes `date +'%Y-%m-%d %H:%M:%S'`" || echo "No changes to commit"
git push origin || echo "No changes to commit"
- name: Push changes # push the output folder to your repo
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.API_TOKEN_GITHUB }}
# WORKFLOW_GITHUB_TOKEN
force: true
- name: Pushes to patoloji-ders-notlari
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
with:
source-directory: 'lecture-notes'
destination-github-username: 'sbalci'
destination-repository-name: 'patoloji-ders-notlari'
user-email: [email protected]
target-branch: main