In the end this is what I did:
name: docs
on:
push:
branches: [ master ]
paths: 'myfolder/*/README.md'
jobs:
docit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Copy the Readmes
run: |
find ./myfolder/ -type f -name "README.md" | while read fname; do
dirname=`dirname "$fname"`
foldername=`basename "$dirname"`
filename=`basename "$fname"`
newname=`echo "$dirname" | sed -e "s/ /_/g"`
cp "${dirname}/$filename" "./docs/_myfolder/${foldername}.md"
done
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git commit -m "Add changes" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
I figured out that I didn't need to look into the frontmatter, since the README was inside a folder with the name I need anyway.
Beware: cp
will nag if you run it the first time and the CI will fail, because you can't have empty folders tracked in git. So I just created an empty dummy file to make sure the "_myfolder" is always there.