Skip to content

Commit

Permalink
Linter, TOC, Pandoc und Anki Action (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve2955 authored Sep 2, 2021
1 parent ee6830a commit 0bba016
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/anki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Create Anki Decks release from markdown

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
convert_via_md2apkg:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- run: npm install -g md2apkg
- run: mkdir output
- run: for f in [A-Z]*[A-Z]-[A-Z]*[A-Z]/README.md; do d=$(echo ${f} | awk -F/ '{print $1}'); md2apkg -o output/${d}.apkg ${f}; done
- uses: actions/upload-artifact@master # upload pdfs as an artifact
with:
name: output
path: output
release_decks:
runs-on: ubuntu-20.04
needs: convert_via_md2apkg
if: github.ref == 'refs/heads/main' # only publish if commited to the main branch
steps:
- name: Retrieve saved Docker image
uses: actions/download-artifact@v2
with:
name: output
path: output
- uses: meeDamian/github-release@2.0 # create/override a release and attach apkgs
with:
token: ${{ secrets.ACCESS_TOKEN }}
tag: anki-release
name: Anki Decks
body: Dieses Release wurde automatisch erstellt
gzip: false
files: output/[A-Z]*[A-Z]-[A-Z]*[A-Z].apkg
allow_override: true
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: markdownlint

on:
push:
branches:
- main
pull_request:

jobs:
linting:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@main
- name: Run mdl
uses: actionshub/markdownlint@main
47 changes: 47 additions & 0 deletions .github/workflows/pandoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Create PDF release from markdown

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
convert_via_pandoc:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: |
mkdir .old &&
rsync -vr ./* .old/ --exclude .old &&
for f in [A-Z]*[A-Z]-[A-Z]*[A-Z]/README.md; do awk '/!\[/{gsub(/<!--/,"{");gsub(/-->/,"}")};{gsub("<!--pagebreak-->","\\pagebreak")};{gsub("<!--newpage-->","\\newpage")};{gsub("<!--clearpage-->","\\clearpage")};{gsub("<!----------","---")};{gsub("---------->","...")};{print}' .old/${f} > ${f} ; done
- run: |
mkdir output
- uses: docker://rstropek/pandoc-latex:latest # generate ABWL-LEDER pdf
with:
entrypoint: /bin/sh
args: -c "for f in [A-Z]*[A-Z]-[A-Z]*[A-Z]/README.md; do d=$(echo ${f} | awk -F/ '{print $1}'); echo ${d}+${f}; pandoc --output=output/${d}.pdf --resource-path=${d}/ --template https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/v2.0.0/eisvogel.tex --pdf-engine=xelatex --listings -f markdown+raw_tex --verbose ${f}; done"
- uses: actions/upload-artifact@master # upload pdfs as an artifact
with:
name: output
path: output
release_pdfs:
runs-on: ubuntu-20.04
needs: convert_via_pandoc
if: github.ref == 'refs/heads/main' # only publish if commited to the main branch
steps:
- name: Retrieve saved Docker image
uses: actions/download-artifact@v2
with:
name: output
path: output
- uses: meeDamian/github-release@2.0 # create/override a release and attach a pdf
with:
token: ${{ secrets.ACCESS_TOKEN }}
tag: pdf-release
name: PDFs
body: Dieses Release wurde automatisch erstellt
gzip: false
files: output/[A-Z]*[A-Z]-[A-Z]*[A-Z].pdf
allow_override: true
17 changes: 17 additions & 0 deletions .github/workflows/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
on:
pull_request:
branches:
- main
name: TOC Generator
jobs:
generateTOC:
runs-on: ubuntu-latest
steps:
- uses: technote-space/toc-generator@v4.1.2
with:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
TOC_TITLE: "**Inhaltsverzeichnis**"
# Git commit name.
COMMIT_NAME: "TOCGEN"
CREATE_PR: false
TARGET_PATHS: "./[A-Z]*[A-Z]-[A-Z]*[A-Z]/README.md"
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# root-level README ############################################################

!/README.md
!/.mdl.rb
!/.mdlrc


# github workflows #############################################################

Expand Down
20 changes: 20 additions & 0 deletions .mdl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Enable all rules by default
all

# Allow any Heading styles
exclude_rule 'MD003'

# First line of the file is not required to be the top-level heading
exclude_rule 'MD041'

# Allow the use of emphasis for small-headers
exclude_rule 'MD036'

# Allow multiple top-level headers per file
exclude_rule 'MD025'

# Extend line length, since each sentence should be on a separate line.
rule 'MD013', :line_length => 200

# Prefix ordered lists with incremental numbers instead of all ones
rule 'MD029', style: 'ordered'
1 change: 1 addition & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style '.mdl.rb'

0 comments on commit 0bba016

Please sign in to comment.