Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | name: Changelog Notification |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: [next] |
| 6 | paths: |
| 7 | - 'docs/content/changelog/**.mdx' |
| 8 | |
| 9 | permissions: |
| 10 | contents: read |
| 11 | |
| 12 | jobs: |
| 13 | notify-changelog: |
| 14 | name: Send Changelog Notification |
| 15 | runs-on: ubuntu-latest |
| 16 | steps: |
| 17 | - name: Checkout Code |
| 18 | uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 19 | with: |
| 20 | fetch-depth: 0 # Fetch full history to detect changes across all commits in push |
| 21 | |
| 22 | - name: Get Changed Changelog Files |
| 23 | id: changed-files |
| 24 | run: | |
| 25 | # Get the commit range for this push |
| 26 | BEFORE="${{ github.event.before }}" |
| 27 | AFTER="${{ github.event.after }}" |
| 28 | |
| 29 | echo "Push event details:" |
| 30 | echo " Before: $BEFORE" |
| 31 | echo " After: $AFTER" |
| 32 | echo " Commits in push: $(git rev-list --count "$BEFORE".."$AFTER" 2>/dev/null || echo "N/A")" |
| 33 | |
| 34 | # Handle first push to branch (before SHA is all zeros) |
| 35 | if [[ "$BEFORE" =~ ^0+$ ]]; then |
| 36 | echo "First push to branch detected, checking only the latest commit" |
| 37 | CHANGED_FILES=$(git diff --name-only --diff-filter=AM HEAD^..HEAD | grep '^docs/content/changelog/.*\.mdx$' || echo "") |
| 38 | else |
| 39 | echo "Checking all commits in push range: $BEFORE..$AFTER" |
| 40 | # Get the list of added/modified changelog files across all commits in this push |
| 41 | CHANGED_FILES=$(git diff --name-only --diff-filter=AM "$BEFORE".."$AFTER" | grep '^docs/content/changelog/.*\.mdx$' || echo "") |
| 42 | fi |
| 43 | |
| 44 | # Skip generated SDK release entries (frontmatter `sdkRelease:`); their release PR covers them. |
| 45 | CHANGED_FILES=$(printf '%s\n' "$CHANGED_FILES" | bash scripts/sdk-release/changelog-filter.sh) |
| 46 | |
| 47 | if [ -z "$CHANGED_FILES" ]; then |
| 48 | echo "No changelog files changed in this push" |
| 49 | echo "has_changelog=false" >> $GITHUB_OUTPUT |
| 50 | else |
| 51 | echo "Changelog files found:" |
| 52 | echo "$CHANGED_FILES" |
| 53 | # Get the first changelog file (in case multiple were added) |
| 54 | CHANGELOG_FILE=$(echo "$CHANGED_FILES" | head -n 1) |
| 55 | echo "" |
| 56 | echo "Processing changelog: $CHANGELOG_FILE" |
| 57 | echo "changelog_file=$CHANGELOG_FILE" >> $GITHUB_OUTPUT |
| 58 | echo "has_changelog=true" >> $GITHUB_OUTPUT |
| 59 | fi |
| 60 | |
| 61 | - name: Extract Changelog Metadata |
| 62 | if: steps.changed-files.outputs.has_changelog == 'true' |
| 63 | id: extract-metadata |
| 64 | run: | |
| 65 | CHANGELOG_FILE="${{ steps.changed-files.outputs.changelog_file }}" |
| 66 | |
| 67 | # Extract title from frontmatter |
| 68 | TITLE=$(grep "^title:" "$CHANGELOG_FILE" | sed "s/^title: *['\"]*//" | sed "s/['\"]* *$//") |
| 69 | |
| 70 | # Extract date from frontmatter |
| 71 | DATE=$(grep "^date:" "$CHANGELOG_FILE" | sed "s/^date: *['\"]*//" | sed "s/['\"]* *$//") |
| 72 | |
| 73 | # Format date for URL (YYYY-MM-DD to YYYY/MM/DD) |
| 74 | URL_DATE=$(echo "$DATE" | sed 's/-/\//g') |
| 75 | |
| 76 | # Build the changelog URL |
| 77 | CHANGELOG_URL="https://docs.composio.dev/docs/changelog/${URL_DATE}" |
| 78 | |
| 79 | # Get the commit author who added/modified this changelog |
| 80 | AUTHOR=$(git log -1 --format='%an' -- "$CHANGELOG_FILE") |
| 81 | AUTHOR_EMAIL=$(git log -1 --format='%ae' -- "$CHANGELOG_FILE") |
| 82 | |
| 83 | # Build properly escaped JSON payload using jq |
| 84 | SLACK_PAYLOAD=$(jq -n \ |
| 85 | --arg title "$TITLE" \ |
| 86 | --arg date "$DATE" \ |
| 87 | --arg url "$CHANGELOG_URL" \ |
| 88 | --arg author "$AUTHOR" \ |
| 89 | '{text: "*New Changelog Published*\n\n*\($title)*\n\nDate: \($date)\n<\($url)|View Changelog>\nAuthor: \($author)"}') |
| 90 | |
| 91 | echo "title=$TITLE" >> $GITHUB_OUTPUT |
| 92 | echo "date=$DATE" >> $GITHUB_OUTPUT |
| 93 | echo "url=$CHANGELOG_URL" >> $GITHUB_OUTPUT |
| 94 | echo "author=$AUTHOR" >> $GITHUB_OUTPUT |
| 95 | echo "author_email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT |
| 96 | |
| 97 | # Save the JSON payload for the next step |
| 98 | echo "slack_payload<<EOF" >> $GITHUB_OUTPUT |
| 99 | echo "$SLACK_PAYLOAD" >> $GITHUB_OUTPUT |
| 100 | echo "EOF" >> $GITHUB_OUTPUT |
| 101 | |
| 102 | echo "📝 Changelog Title: $TITLE" |
| 103 | echo "📅 Date: $DATE" |
| 104 | echo "🔗 URL: $CHANGELOG_URL" |
| 105 | echo "👤 Author: $AUTHOR ($AUTHOR_EMAIL)" |
| 106 | |
| 107 | - name: Send Slack Notification |
| 108 | if: steps.changed-files.outputs.has_changelog == 'true' |
| 109 | uses: slackapi/slack-github-action@dcb1066f776dd043e64d0e8ba94ca15cc7e1875d # v4.0.0 |
| 110 | with: |
| 111 | webhook: ${{ secrets.SLACK_CUSTOMER_COMMS_WEBHOOK_URL }} |
| 112 | webhook-type: incoming-webhook |
| 113 | payload: ${{ steps.extract-metadata.outputs.slack_payload }} |