Files
posthog.com/.github/workflows/sales-handbook-notify.yml
Cory Watilo 15c925b43d version bump (#12254)
Co-authored-by: Cory Watilo <corywatilo@gmail.com>
Co-authored-by: Eli Kinsey <eli@ekinsey.dev>
Co-authored-by: Lucas Faria <12522524+lucasheriques@users.noreply.github.com>
Co-authored-by: Ben White <ben@posthog.com>
Co-authored-by: Juraj Majerik <juro.majerik@gmail.com>
Co-authored-by: Rafael Audibert <32079912+rafaeelaudibert@users.noreply.github.com>
2025-09-10 16:33:30 +00:00

126 lines
5.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Sales Handbook Change Notification
permissions:
contents: read
on:
push:
branches: [master, main]
paths:
- 'contents/handbook/growth/sales/**'
jobs:
notify-sales-team:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2 # Get current and previous commit for comparison
- name: Get changed files
id: changed-files
run: |
# Get the list of changed files in the sales handbook directory
CHANGED_FILES=$(git diff --name-status HEAD~1 HEAD -- contents/handbook/growth/sales/ | head -20)
# Format the changes for Slack
echo "CHANGED_FILES<<EOF" >> $GITHUB_OUTPUT
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Get commit info
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an")
COMMIT_HASH=$(git log -1 --pretty=format:"%h")
COMMIT_URL="https://github.com/${{ github.repository }}/commit/${{ github.sha }}"
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
echo "COMMIT_AUTHOR=$COMMIT_AUTHOR" >> $GITHUB_OUTPUT
echo "COMMIT_HASH=$COMMIT_HASH" >> $GITHUB_OUTPUT
echo "COMMIT_URL=$COMMIT_URL" >> $GITHUB_OUTPUT
- name: Format file changes
id: format-changes
run: |
# Process the changed files and format them nicely
CHANGES="${{ steps.changed-files.outputs.CHANGED_FILES }}"
ADDED_FILES=""
MODIFIED_FILES=""
DELETED_FILES=""
while IFS=$'\t' read -r status file; do
if [ -n "$file" ]; then
filename=$(basename "$file")
case "$status" in
"A")
ADDED_FILES="$ADDED_FILES• Added: $filename\n"
;;
"M")
MODIFIED_FILES="$MODIFIED_FILES• ✏️ Modified: $filename\n"
;;
"D")
DELETED_FILES="$DELETED_FILES• ❌ Deleted: $filename\n"
;;
esac
fi
done <<< "$CHANGES"
# Combine all changes
ALL_CHANGES="$ADDED_FILES$MODIFIED_FILES$DELETED_FILES"
# Remove trailing newline
ALL_CHANGES=$(echo -e "$ALL_CHANGES" | sed '$d')
echo "ALL_CHANGES<<EOF" >> $GITHUB_OUTPUT
echo -e "$ALL_CHANGES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: custom
custom_payload: |
{
"channel": "#sales-alerts",
"attachments": [
{
"color": "good",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "📚 Sales Handbook Updated"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Commit:* ${{ steps.changed-files.outputs.COMMIT_MESSAGE }}\n*Author:* ${{ steps.changed-files.outputs.COMMIT_AUTHOR }}\n*Hash:* `${{ steps.changed-files.outputs.COMMIT_HASH }}`"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*📝 Changes:*\n${{ steps.format-changes.outputs.ALL_CHANGES }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*🔗 Links:*\n• <${{ steps.changed-files.outputs.COMMIT_URL }}|View Commit>\n• <https://github.com/${{ github.repository }}/tree/${{ github.sha }}/contents/handbook/growth/sales|View Sales Handbook>"
}
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_SALES_WEBHOOK }}