Skip to content

Instantly share code, notes, and snippets.

@ravenclaw900
Last active May 30, 2020 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravenclaw900/256b1037a1f2d872165fdbea18aa0d97 to your computer and use it in GitHub Desktop.
Save ravenclaw900/256b1037a1f2d872165fdbea18aa0d97 to your computer and use it in GitHub Desktop.
A YAML Github Actions file to build a dtx file from various other files
# Build a .dtx file from the contents of the existing files
name: Build DTX File
# Controls when the action will run. Triggers the workflow on push events on the develop branch
on:
push:
branches: [ develop ]
jobs:
# This workflow contains a single job called "build"
build:
# This runs on the current latest verion of Ubuntu
runs-on: ubuntu-18.04
steps:
# Checks-out the repository under $GITHUB_WORKSPACE, so the job can access it
- name: Check-out repository
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
# Cds to the repo
- name: Move to the repo
run: cd $GITHUB_WORKSPACE
# Gets the list of files to put into the dtx file
- name: Get the list of files needed
run: find ./src -not -path '*/\.*' -type f > /home/runner/paths.txt
# Creates the dtx file
- name: (Re)create the dtx file
run: "> ./dnd.dtx"
# The main step: puts the contents of each .sty file into the dtx file and adds the appropriate tags
- name: Populate the dtx file
run: while read -r path; do fileext=$(basename -- "$path"); filename="${fileext%.*}"; echo '%<*'"$filename"'>' >> dnd.dtx; cat "$path" >> dnd.dtx; echo '%</'"$filename"'>' >> dnd.dtx; done < /home/runner/paths.txt
# Doubles comments so they don't get stripped
- name: Fix comments
run: perl -i -p -e "s/^\%(?!\%)(?!\<\*)(?!\<\/)/\%\%/mg" dnd.dtx
# Adds \iffalse and \fi at the beginning and end for docstrip
- name: Add other necessary parts
run: ex -sc '1i|% \iffalse' -c '$a|% \fi' -cx dnd.dtx
# Pushes the final file to the repository
- name: Push dtx file back to repository
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Auto-update dnd.dtx
branch: develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment