Skip to content

docs: add CLI v0.36.6 changelog entry (#530) #29

docs: add CLI v0.36.6 changelog entry (#530)

docs: add CLI v0.36.6 changelog entry (#530) #29

name: Post Changelog to Discord and Reddit
on:
push:
branches: [main]
paths:
- 'docs/changelog/*.mdx'
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed changelog files
id: changes
run: |
CHANGED_FILES=$(git diff --name-only HEAD^ HEAD | grep 'docs/changelog/' || echo "")
echo "Changed files: $CHANGED_FILES"
if [ -n "$CHANGED_FILES" ]; then
# Get the first changed file
FIRST_FILE=$(echo "$CHANGED_FILES" | head -n 1)
echo "file=$FIRST_FILE" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.changes.outputs.file != ''
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Parse changelog and post to Discord
if: steps.changes.outputs.file != ''
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
CHANGELOG_FILE: ${{ steps.changes.outputs.file }}
run: |
if [ -z "${DISCORD_WEBHOOK_URL}" ]; then
echo "Discord webhook URL not provided. Skipping Discord notification."
else
# Parse the changelog
MESSAGE=$(node .github/scripts/parse-changelog.js "$CHANGELOG_FILE")
if [ -z "$MESSAGE" ]; then
echo "Failed to parse changelog for Discord"
exit 1
fi
echo "Posting to Discord:"
echo "$MESSAGE"
# Create JSON payload
PAYLOAD=$(jq -n --arg content "$MESSAGE" '{
content: $content
}')
# Post to Discord
curl -X POST \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"$DISCORD_WEBHOOK_URL"
echo "Successfully posted to Discord!"
fi
- name: Post to Reddit
if: steps.changes.outputs.file != ''
env:
REDDIT_CLIENT_ID: ${{ secrets.REDDIT_CLIENT_ID }}
REDDIT_CLIENT_SECRET: ${{ secrets.REDDIT_CLIENT_SECRET }}
REDDIT_USERNAME: ${{ secrets.REDDIT_USERNAME }}
REDDIT_PASSWORD: ${{ secrets.REDDIT_PASSWORD }}
REDDIT_SUBREDDIT: 'factoryai'
CHANGELOG_FILE: ${{ steps.changes.outputs.file }}
run: |
if [ -z "${REDDIT_CLIENT_ID}" ]; then
echo "Reddit credentials not provided. Skipping Reddit notification."
else
echo "Posting to Reddit..."
node .github/scripts/post-to-reddit.js "$CHANGELOG_FILE"
fi