diff --git a/.github/workflows/discord-monitor.yml b/.github/workflows/discord-monitor.yml new file mode 100644 index 0000000000000000000000000000000000000000..191b0eff609716ad18ea60583d64f7ac22ca1265 --- /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: + 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 0000000000000000000000000000000000000000..13a5b66d338f4d1139e6c05fe38b924fb69c10ff --- /dev/null +++ b/.github/workflows/discord-notify.yml @@ -0,0 +1,26 @@ +name: Discord Release Notification + +on: + release: + types: [published] + +jobs: + notify-discord: + name: Notify Discord Channel + runs-on: ubuntu-latest + if: github.event.release.tag_name != 'nightlyv0' + + 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 Matcha release has been published!**\n\n**Release:** ${{ github.event.release.name }}\n\nCheck it out here: ${{ github.event.release.html_url }}" + }' \ + $DISCORD_WEBHOOK_URL