diff --git a/.github/workflows/discord-monitor.yml b/.github/workflows/discord-monitor.yml new file mode 100644 index 0000000..194fc64 --- /dev/null +++ b/.github/workflows/discord-monitor.yml @@ -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 diff --git a/.github/workflows/discord-notify.yml b/.github/workflows/discord-notify.yml new file mode 100644 index 0000000..76793d3 --- /dev/null +++ b/.github/workflows/discord-notify.yml @@ -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 diff --git a/.github/workflows/mastodon-notify.yml b/.github/workflows/mastodon-notify.yml new file mode 100644 index 0000000..492670f --- /dev/null +++ b/.github/workflows/mastodon-notify.yml @@ -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"