Problem #
Simple GitHub action for publishing articles to prose.sh.
Solution #
Use the following action:
1## File: .github/workflows/publish.yaml
2name: Publish blog
3"on":
4 push:
5 branches:
6 - main
7jobs:
8 publish:
9 runs-on: ubuntu-latest
10 permissions:
11 contents: read
12 steps:
13 - uses: actions/checkout@v5
14 with:
15 fetch-depth: 2
16 - uses: webfactory/ssh-agent@v0.9.1
17 with:
18 ssh-private-key: ${{ secrets.PICO_PRIVATE_KEY }}
19 - id: modified-files
20 run: echo "articles=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -- '*.md' | tr '\n' ' ')" >> "$GITHUB_OUTPUT"
21 - run: rsync -e 'ssh -o StrictHostKeyChecking=no' ${{ steps.modified-files.outputs.articles }} prose.sh:/
Explanation #
A private key is required to authenticate with the remote server. The private key is stored as a secret in the GitHub repository settings.
Only markdown files that were modified since the last commit will be published to prose.sh.
Considerations #
This action works on push events. If you use pull_request events, you can update the "articles" echo command to git diff --name-only HEAD^1 HEAD -- '*.md' instead.
last updated: