Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/discord-monitor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Flotpane Activity Monitor

on:
push:
issues:
types: [opened, edited, deleted, closed, reopened]
pull_request_target:
types: [opened, edited, closed, reopened]
issue_comment:
types: [created, deleted]
fork:
watch:
types: [started] # This triggers when someone stars the repo
discussion:
types: [created, answered]

jobs:
discord-audit-log:
name: Send Discord Audit Log
runs-on: ubuntu-latest
steps:
- name: Parse Event and Send Webhook
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL_AUDIT_LOG }}
run: |
EVENT_NAME="${{ github.event_name }}"
ACTOR="${{ github.actor }}"
REPO="${{ github.repository }}"
ACTION="${{ github.event.action }}"

# Default fallback URL
URL="https://github.com/$REPO"

# Customize Title and URL based on the specific event
if [ "$EVENT_NAME" == "issues" ]; then
TITLE="🐛 Issue $ACTION in $REPO"
URL="${{ github.event.issue.html_url }}"
elif [ "$EVENT_NAME" == "pull_request" ]; then
TITLE="🔄 Pull Request $ACTION in $REPO"
URL="${{ github.event.pull_request.html_url }}"
elif [ "$EVENT_NAME" == "push" ]; then
TITLE="⬆️ Code Pushed to $REPO"
URL="${{ github.event.compare }}" # Links to the commit comparison
elif [ "$EVENT_NAME" == "issue_comment" ]; then
TITLE="💬 Comment $ACTION on an Issue/PR"
URL="${{ github.event.comment.html_url }}"
elif [ "$EVENT_NAME" == "watch" ]; then
TITLE="⭐ Repo Starred!"
elif [ "$EVENT_NAME" == "fork" ]; then
TITLE="🍴 Repo Forked!"
elif [ "$EVENT_NAME" == "discussion" ]; then
TITLE="🗣️ Discussion $ACTION"
URL="${{ github.event.discussion.html_url }}"
else
TITLE="🔔 Activity ($EVENT_NAME) in $REPO"
fi

# Use jq to safely build the JSON payload (prevents special characters from breaking the script)
# Color is set to 0 (Pitch Black) to match the Flotpane branding
jq -n \
--arg title "$TITLE" \
--arg url "$URL" \
--arg desc "**User:** \`$ACTOR\` triggered \`$EVENT_NAME\`.\n\n[**View this activity on GitHub**]($url)" \
'{
username: "Flotpane Monitor",
avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
embeds: [{
title: $title,
url: $url,
description: $desc,
color: 0
}]
}' | curl -H "Content-Type: application/json" -d @- $DISCORD_WEBHOOK_URL
25 changes: 25 additions & 0 deletions .github/workflows/discord-notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Discord Release Notification

on:
release:
types: [published]

jobs:
notify-discord:
name: Notify Discord Channel
runs-on: ubuntu-latest

steps:
- name: Send Discord Message
env:
# Pulls the secure webhook URL from your repository secrets
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
curl -H "Content-Type: application/json" \
-X POST \
-d '{
"username": "GitHub Releases",
"avatar_url": "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
"content": "🚀 **A new Lattice release has been published!**\n\n**Release:** ${{ github.event.release.name }}\n\nCheck it out here: ${{ github.event.release.html_url }}"
}' \
$DISCORD_WEBHOOK_URL
24 changes: 24 additions & 0 deletions .github/workflows/mastodon-notify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Announce Release on Fosstodon

on:
release:
types: [published]

jobs:
post-to-fosstodon:
if: github.event.release.prerelease == false
runs-on: ubuntu-latest
steps:
- name: Send Post to Fosstodon
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MESSAGE: |
Release ${{ github.event.release.tag_name }} of Lattice is out!
Check it out! ${{ github.event.release.html_url }}
run: |
JSON_PAYLOAD=$(jq -n --arg status "$MESSAGE" '{status: $status}')

curl -sS -X POST "https://fosstodon.org/api/v1/statuses" \
-H "Authorization: Bearer $MASTODON_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD"