Compile MD file #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Compile MD file" | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
compile-and-push: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout imagej.github.io | |
uses: actions/checkout@v3 | |
with: | |
repository: 'royerlab/imagej.github.io' | |
path: 'imagej.github.io' | |
- name: Checkout this repository | |
uses: actions/checkout@v3 | |
with: | |
path: 'ultrack-imagej' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Find and copy media files | |
run: | | |
FILES=$(grep -oP '!\[.*?\]\(\K.*?(?=\))' "imagej.github.io/_pages/plugins/ultrack.md") | |
for FILE in $FILES; | |
do | |
mkdir -p "ultrack-imagej/$(dirname "$FILE")" | |
cp "imagej.github.io/$FILE" "ultrack-imagej/$FILE" | |
done | |
cp imagej.github.io/_pages/plugins/ultrack.md ultrack-imagej/README.md | |
- name: Remove ImageJ includes | |
run: | | |
cd ultrack-imagej | |
sed -i '/^{%/d' README.md | |
sed -z -i 's/---.*---//g' README.md | |
sed -z -i 's/\/media/media/g' README.md | |
{ cat header.md; cat README.md; cat citation.md;} > temp && mv temp README.md | |
- name: Commit | |
run: | | |
cd ultrack-imagej | |
if git diff --exit-code; then | |
echo "No changes to commit." | |
exit 0 | |
else | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "Update README.md" | |
git push origin main | |
fi |