Skip to content

Render README

Render README #12

Workflow file for this run

name: Render README
on:
workflow_dispatch:
inputs:
r-version:
description: 'The version of R to use'
default: 'release'
required: false
type: choice
options:
- devel
- latest
skip-md-formatting:
description: 'Skip markdown auto-formatting'
default: false
required: false
type: boolean
workflow_call:
inputs:
r-version:
description: 'The version of R to use'
default: 'release'
required: false
type: string
skip-md-formatting:
description: 'Skip markdown auto-formatting'
default: false
required: false
type: boolean
jobs:
render:
name: Render
runs-on: ubuntu-latest
container:
image: "ghcr.io/pharmaverse/admiralci-${{ inputs.r-version }}:latest"
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
##################### BEGIN boilerplate steps #####################
- name: Get branch names
id: branch-name
uses: tj-actions/[email protected]
- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: "${{ secrets.PHARMAVERSE_BOT }}"
- name: Checkout repository
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
token: "${{ secrets.PHARMAVERSE_BOT }}"
- name: Normalize inputs
id: normalizer
run: |
R_VERSION="${{ inputs.r-version }}"
if [ "$R_VERSION" == "" ]
then {
R_VERSION="4.1"
}
fi
echo "R_VERSION=$R_VERSION" >> $GITHUB_OUTPUT
shell: bash
- name: Restore cache
uses: actions/cache@v3
with:
path: |
~/.staged.dependencies
key: staged-deps
- name: Run Staged dependencies
uses: insightsengineering/staged-dependencies-action@v1
with:
run-system-dependencies: false
renv-restore: false
enable-check: false
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies from DESCRIPTION
run: |
remotes::install_local(force = TRUE, dependencies = TRUE)
shell: Rscript {0}
##################### END boilerplate steps #####################
- name: Render README to markdown
run: |
if (file.exists("README.Rmd")) {
rmarkdown::render("README.Rmd", output_format = "md_document")
}
shell: Rscript {0}
env:
BRANCH_NAME: "${{ steps.branch-name.outputs.current_branch }}"
- name: Install Markdown formatter
if: ${{ !inputs.skip-md-formatting }}
run: |
npm install -g n # upgrade node version to use markdown-formatter
n latest
n prune
hash -r
node --version
npm install -g @quilicicf/markdown-formatter
shell: bash
- name: Commit and push formatted README.md
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: templates data updates from ${{ github.repository }}
file_pattern: 'README.md'
commit_user_name: pharmaverse-bot
commit_user_email: [email protected]
branch: "${{ steps.branch-name.outputs.head_ref_branch }}"