Skip to content

Github action to render documents using rmarkdown. Includes pandoc and tinytex installations

License

Notifications You must be signed in to change notification settings

lucharo/rmarkdown-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Test multiple format rendering Render and upload docs

rmarkdown-action

Github action to render documents using rmarkdown. Uses rocker/r-rmd docker image which includes rmardkown, pandoc and latex.

Inputs

  • input_file: path or name of input file, all with respect to root directory of the repo (e.g: my_doc.Rmd, path/to/my_doc.Rmd)
  • output_format: (defaults to pdf_document), options are: word_document, html_document and pdf_document.

Outputs

  • output_file: This is automatically generated as the name that precedes .Rmd + the output format extension (e.g: for my_doc.Rmd with output_format as pdf_document -> my_doc.pdf

Disclaimer: By default, the rmarkdown-action will simply render the document to desired format. If you also wish to upload the document back to the repo please see the later section

Example

name: Render documents with rmarkdown-action
on: [push]
jobs:
  render_document:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
      - name: Render document
        uses: lc5415/rmarkdown-action@v1
        with:
          input_file: path/to/my_doc.Rmd
	  output_format: pdf_document

Other powerful usages

Uploading rendered document to GitHub

This makes use of the github-push-action to automatically upload the rendered document to the branch that trigerred the rmarkdown-action. This is useful when the quality of the rendering needs to be reviewed as well (which is almost always the case).

By default, the rendered document will be uploaded to the same location that the input file. If you want to be able to specify the output location please submit an issue.

name: Render documents and upload

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  render_document:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Git repository
        uses: actions/checkout@v2
      - name: Render document
        uses: lc5415/rmarkdown-action@v1
        with:
          input_file: path/to/my_doc.Rmd
	  output_format: pdf_document
      - name: Commit files
        run: |
          git config --local core.autocrlf false
          git config --local user.email "${{ github.actor }}@users.noreply.github.com"
          git config --local user.name "${{ github.actor }}"
          git add . && git add --renormalize .
          git pull origin ${{ github.head_ref }} --autostash --rebase -X ours
          git commit --allow-empty -am "AUTO-GH ACTION: ${{ github.workflow }}"
          NO_PAGER=1 git --no-pager diff HEAD^
      - name: Push changes
        uses: ad-m/github-push-action@master
        with:
          branch: ${{ github.head_ref }}
          github_token: ${{ secrets.GITHUB_TOKEN }}

About

Github action to render documents using rmarkdown. Includes pandoc and tinytex installations

Resources

License

Stars

Watchers

Forks

Packages

No packages published