Skip to content
name: Post Wordpress Random Cases
on:
workflow_dispatch:
push:
schedule:
- cron: '0 18 * * 1'
jobs:
post-wordpress-random-cases-from-patolojiatlasi:
if: "!contains(github.event.head_commit.message, 'WIP')"
runs-on: macos-latest
# runs-on: ubuntu-latest
env:
RENV_PATHS_ROOT: ~/.local/share/renv
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "actions checkout"
uses: actions/checkout@v3
- uses: r-lib/actions/setup-r@v2
- name: Restore R package cache
uses: actions/cache@v3
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version2') }}-1-${{ hashFiles('.github/depends2.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version2') }}-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")}
renv::restore()
if (!requireNamespace("magrittr", quietly = TRUE)) {install.packages("magrittr", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("dplyr", quietly = TRUE)) {install.packages("dplyr", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("RCurl", quietly = TRUE)) {install.packages("RCurl", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("XML", quietly = TRUE)) {install.packages("XML", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("XMLRPC", quietly = TRUE)) {remotes::install_github("duncantl/XMLRPC", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("RWordPress", quietly = TRUE)) {remotes::install_github("duncantl/RWordPress", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("knitr", quietly = TRUE)) {install.packages("knitr", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
if (!requireNamespace("svDialogs", quietly = TRUE)) {install.packages("svDialogs", dependencies = TRUE, quiet = TRUE, verbose = FALSE)}
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends2.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version2")
shell: Rscript {0}
- name: generate and post wp_string
env:
WP_USER_NAME: ${{ secrets.WP_USER_NAME }}
WP_USER_SECRET: ${{ secrets.WP_USER_SECRET }}
WP_USER_SITE: ${{ secrets.WP_USER_SITE }}
WP_LOG: ${{ secrets.WP_LOG }}
run: |
# read environment variables
WP_USER_NAME <- Sys.getenv("WP_USER_NAME")
WP_USER_SECRET <- Sys.getenv("WP_USER_SECRET")
WP_USER_SITE <- Sys.getenv("WP_USER_SITE")
options(WordpressURL = paste0('https://', WP_USER_SITE ,'.wordpress.com', '/xmlrpc.php'))
WordpressLogin <- c(WP_USER_SECRET)
names(WordpressLogin) <- WP_USER_NAME
options(WordpressLogin = WordpressLogin)
options(knitr.knit2wp.warning = FALSE)
source('./R/extract-html-links-EN.R')
titleWP <- readLines("./text_heading.txt")
textWP <- readLines("./text_body.txt")
RWordPress::newPost(content = list(title = titleWP,
description = paste0('<p>',
textWP,
'</p>'),
categories = c('patolojiatlasi',
'histopathologyatlas',
'patolojinotlari')),
publish = TRUE)
shell: Rscript {0}