Create backup of hackmd notes bypassing the API #1988
This file contains hidden or 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: Create backup of hackmd notes bypassing the API | |
| on: | |
| schedule: | |
| # - cron: "15 3/4 * * 0-6" # At 3:15, 7:15, 11:15, 15:15, 19:15, 23:15 on every day-of-week. | |
| # During "Central European Time" (CET): Offset from UTC: -1 | |
| - cron: '15 2/4 * 11-12,1-3 0-6' | |
| # During "Central European Summer Time" (CEST): Offset from UTC: -2 | |
| - cron: '15 1/4 * 4-10 0-6' | |
| workflow_dispatch: | |
| permissions: write-all | |
| jobs: | |
| run: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: mkdir -p hackmd-backup/_fetched | |
| - run: curl -L https://hackmd.io/@DSE-AS/Editionsmodell/edit > hackmd-backup/_fetched/editionsmodell.html | |
| - run: curl -L https://hackmd.io/@DSE-AS/Transkribus_Dokumentation/edit > hackmd-backup/_fetched/transkribus-dokumentation.html | |
| - run: curl -L https://hackmd.io/@DSE-AS/ryMYDZtnA/edit > hackmd-backup/_fetched/interface-model-dseas.html | |
| - run: curl -L https://hackmd.io/@DSE-AS/SyjEFFl9yg/edit > hackmd-backup/_fetched/register-model-dseas.html | |
| - run: curl -L https://hackmd.io/@DSE-AS/H1aXACCi1g/edit > hackmd-backup/_fetched/oxygen-docu.html | |
| - name: Install pup | |
| run: | | |
| go install github.com/ericchiang/pup@latest | |
| echo "$HOME/go/bin" >> $GITHUB_PATH | |
| - name: Extract doc div using pup (to get rid of illegal characters in XML 1.0) | |
| run: | | |
| for f in hackmd-backup/_fetched/*.html; do | |
| pup 'div#doc' < "$f" > "${f%.*}.xhtml" || echo "No div#doc found in $f" | |
| done | |
| - run: cat hackmd-backup/_fetched/interface-model-dseas.html | |
| - run: cat hackmd-backup/_fetched/interface-model-dseas.xhtml | |
| - name: process hackmd.io HTML (XSLT) | |
| uses: pdaengeli/[email protected] | |
| with: | |
| args: -xsl:hackmd-backup/process-hackmd.xsl -it | |
| - run: mkdir -p src/_fetched/transkribus-dokumentation src/_fetched/editionsmodell src/_fetched/interface-model-dseas src/_fetched/register-model-dseas src/_fetched/oxygen-docu | |
| - run: tree hackmd-backup | |
| - run: cat hackmd-backup/_fetched/img-urls.txt | |
| - run: curl -L -K hackmd-backup/_fetched/img-urls.txt | |
| - uses: actions/upload-pages-artifact@v3 | |
| with: | |
| name: output | |
| path: ./hackmd-backup | |
| env: | |
| RUNNER: ${{ toJson(runner) }} | |
| - name: Set commit message | |
| id: commit_message_step | |
| run: | | |
| delimiter='EOF' | |
| { | |
| echo "commit_message<<$delimiter" | |
| sed -e '$a\' hackmd-backup/.commit-message.txt | |
| echo "$delimiter" | |
| } >> "$GITHUB_OUTPUT" | |
| rm -r hackmd-backup/.commit-message.txt | |
| - uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: ${{ steps.commit_message_step.outputs.commit_message }} | |
| file_pattern: 'src/_fetched/*.md src/_fetched/**/*.png' | |
| skip_fetch: true |