Skip to content

Community Extensions Watcher #88

Community Extensions Watcher

Community Extensions Watcher #88

name: Community Extensions Watcher
on:
workflow_dispatch:
inputs:
announce:
description: "Set to 'true' to announce new or updated extensions, 'false' to only sync data."
required: false
default: "true"
schedule:
- cron: '0 */6 * * *'
jobs:
fetch_new_extensions:
runs-on: ubuntu-latest
env:
REMOTE_REPO_URL: "https://github.com/duckdb/community-extensions.git"
STATE_DIR: "extensions/"
steps:
- name: Checkout this repository
uses: actions/checkout@v4
- name: Set up state directory
run: |
mkdir -p ${{ env.STATE_DIR }}
echo "State directory initialized."
- name: Clone remote repository
run: |
git clone ${{ env.REMOTE_REPO_URL }} remote-repo
cd remote-repo
git fetch
- name: Parse and stash `description.yml` files
run: |
cd remote-repo/extensions
mkdir -p ../../${{ env.STATE_DIR }}
# Iterate through each extension directory
for dir in */; do
extension_name=${dir%/}
echo "Processing $extension_name"
# Check if description.yml exists
if [ -f "$dir/description.yml" ]; then
# Read version from the current description.yml
version=$(yq e '.extension.version' "$dir/description.yml")
# Create directory for this extension's state
mkdir -p ../../${{ env.STATE_DIR }}/$extension_name
stashed_description="../../${{ env.STATE_DIR }}/$extension_name/description.yml"
# Compare with the stashed version (if exists)
if [ -f "$stashed_description" ]; then
stashed_version=$(yq e '.extension.version' "$stashed_description")
else
stashed_version="none"
fi
# Save the current description.yml to the state directory
cp "$dir/description.yml" "$stashed_description"
# Check if the extension is new or updated
if [ "$version" != "$stashed_version" ]; then
echo "$extension_name: New or updated version detected (current: $version, previous: $stashed_version)"
echo "$extension_name" >> ../../${{ env.STATE_DIR }}/updated_extensions.txt
fi
else
echo "$extension_name: No description.yml found."
fi
done
- name: Announce new or updated extensions
if: inputs.announce == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
if [ -f ${{ env.STATE_DIR }}/updated_extensions.txt ]; then
cat ${{ env.STATE_DIR }}/updated_extensions.txt | while read extension_name; do
# Read the description.yml for details
description_file="${{ env.STATE_DIR }}/$extension_name/description.yml"
name=$(yq e '.extension.name' "$description_file")
description=$(yq e '.extension.description' "$description_file")
version=$(yq e '.extension.version' "$description_file")
github=$(yq e '.repo.github' "$description_file")
url="https://duckdb.org/community_extensions/extensions/${extension_name}.html"
# Format the post content
post_content="🎉 New Community Extension: $name ($version) $url"
echo "$post_content"
# Announce the update (e.g., via Bluesky or other platform)
gh workflow run Post-on-Bluesky \
--ref main \
-f post="$post_content"
done
else
echo "No new or updated extensions to announce."
fi
- name: Commit and push state updates
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ${{ env.STATE_DIR }}
git commit -m "Update state for community extensions" || echo "No changes to commit"
git push