Skip to content

Commit

Permalink
Docs: R Markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar committed Jun 22, 2022
1 parent 5ef4582 commit f5c7f39
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: "docs"

on:
pull_request:
types: [ "opened", "synchronize", "edited", "reopened" ]
push:
branches:
- "**"

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref_name }}"
cancel-in-progress: true

jobs:
convert:
name: "Convert R Markdown files to regular Markdown"
runs-on: "ubuntu-latest"
env:
R_COMPILE_AND_INSTALL_PACKAGES: "never"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Rrrr DESCRIPTION file"
run: |
cat <<EOF >DESCRIPTION
Package: Rrrrrrrrr Markdown generator
Version: 0.1
EOF
- name: "Rrrr"
uses: "r-lib/actions/setup-r@v1"

- name: "Rrrr dependencies"
uses: "r-lib/actions/setup-r-dependencies@v2"
with:
cache-version: 1
extra-packages: |
any::rmarkdown
- name: "Pandoc"
uses: "r-lib/actions/setup-pandoc@v1"

- name: "Find removed files"
uses: "dorny/paths-filter@v2"
id: "removed"
with:
list-files: "shell"
filters: |
Rmd:
- removed: '*.Rmd'
- name: "Cleanup"
run: |
for Rmd in ${{ steps.removed.outputs.Rmd }}
do
md="${Rmd%.*}.md"
rm $md
done
- name: "Find changed files"
uses: "dorny/paths-filter@v2"
id: "changed"
with:
list-files: "shell"
filters: |
Rmd:
- '*.Rmd'
- name: "Convert"
run: |
for Rmd in ${{ steps.changed.outputs.Rmd }}
do
Rscript -e 'rmarkdown::render("$Rmd", output_format = "md_document")'
done
- name: "Commit"
run: |
git add *.md
git -vm "Build .md files from .Rmd" || echo "No changes to commit"
git push origin || true
status-check:
name: "Status check - docs"
runs-on: "ubuntu-latest"
needs: [ "convert" ]

if: "${{ always() }}"

steps:
- name: "Check required jobs are successful"
env:
RESULTS: "${{ join(needs.*.result, ' ') }}"
run: |
for res in $RESULTS
do
if [ $res != 'success' ]; then
exit 1
fi
done
File renamed without changes.

0 comments on commit f5c7f39

Please sign in to comment.