Sync Obsidian Plugin Releases #233
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: Sync Obsidian Plugin Releases | |
| on: | |
| schedule: | |
| - cron: '0 */6 * * *' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Fetch and process releases | |
| env: | |
| GH_TOKEN: ${{ secrets.OBSIDIAN_REPO_PAT }} | |
| run: | | |
| mkdir -p website/src/content/docs/releases | |
| RELEASES=$(gh api repos/dannysmith/obsidian-taskdn/releases \ | |
| --jq '[.[] | select(.draft == false and .prerelease == false)]') | |
| echo "$RELEASES" | jq -c '.[]' | while read -r release; do | |
| TAG=$(echo "$release" | jq -r '.tag_name') | |
| VERSION="${TAG#v}" | |
| FILENAME="website/src/content/docs/releases/obsidian-${VERSION}.mdx" | |
| if [ -f "$FILENAME" ]; then | |
| continue | |
| fi | |
| DATE=$(echo "$release" | jq -r '.published_at' | cut -d'T' -f1) | |
| BODY=$(echo "$release" | jq -r '.body // "No release notes provided."') | |
| URL=$(echo "$release" | jq -r '.html_url') | |
| { | |
| printf '%s\n' "---" | |
| printf '%s\n' "title: 'Obsidian Plugin v${VERSION}'" | |
| printf '%s\n' "description: 'Release notes for Obsidian Plugin v${VERSION}'" | |
| printf '%s\n' "date: ${DATE}" | |
| printf '%s\n' "product: obsidian" | |
| printf '%s\n' "---" | |
| printf '\n' | |
| printf '%s\n' "$BODY" | |
| printf '\n' | |
| printf '%s\n' "---" | |
| printf '\n' | |
| printf '%s\n' "[View on GitHub](${URL})" | |
| } > "$FILENAME" | |
| echo "Created: $FILENAME" | |
| done | |
| - name: Commit if changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add website/src/content/docs/releases/ | |
| if git diff --cached --quiet; then | |
| echo "No new releases to sync" | |
| else | |
| git commit -m "docs(releases): sync obsidian plugin releases" | |
| git push | |
| fi |