Skip to content

Fix Discord invite link #5

Fix Discord invite link

Fix Discord invite link #5

name: Sponsor Team Manager

Check failure on line 1 in .github/workflows/sponsor-manager.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/sponsor-manager.yml

Invalid workflow file

(Line: 3, Col: 3): Unexpected value 'sponsorship'
on:
sponsorship:
types: [created, cancelled, tier_changed, pending_cancellation]
jobs:
manage-sponsor:
runs-on: ubuntu-latest
steps:
- name: Handle sponsor event
uses: actions/github-script@v7
env:
DISCORD_BOT_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
with:
github-token: ${{ secrets.ORG_ADMIN_TOKEN }}
script: |
const event = context.payload;
const sponsor = event.sponsorship.sponsor.login;
const tierName = event.sponsorship.tier.name;
const tierPrice = event.sponsorship.tier.monthly_price_in_dollars;
const action = event.action;
const org = 'AnkleBreaker-Studio';
const teamSlug = 'sponsors';
const MIN_TIER_PRICE = 15;
const DISCORD_CHANNEL = '1476975591692435620';
async function postDiscord(message) {
try {
const resp = await fetch(
`https://discord.com/api/v10/channels/${DISCORD_CHANNEL}/messages`,
{
method: 'POST',
headers: {
'Authorization': `Bot ${process.env.DISCORD_BOT_TOKEN}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ content: message })
}
);
if (!resp.ok) console.error(`Discord error: ${resp.status}`);
} catch (e) { console.error(`Discord post failed: ${e.message}`); }
}
if (action === 'created' || action === 'tier_changed') {
if (tierPrice >= MIN_TIER_PRICE) {
try {
await github.rest.teams.addOrUpdateMembershipForUserInOrg({
org, team_slug: teamSlug, username: sponsor, role: 'member'
});
console.log(`Added ${sponsor} to sponsors team`);
} catch (error) {
console.error(`Failed to add ${sponsor}: ${error.message}`);
}
if (action === 'created') {
if (tierPrice >= 100) {
await postDiscord(
`## \ud83d\udd34 New MCP Priority Support Subscriber!\n\n` +
`**${sponsor}** just joined as an **${tierName}** subscriber! Welcome to the inner circle! \u2764\ufe0f\n\n` +
`Thank you for your incredible support of AnkleBreaker Studio! You now have priority access to our team. \ud83d\ude80\n\n` +
`> Don't forget to claim your **MCP Priority Support** Discord role in the [premium-mcps repo](https://github.com/AnkleBreaker-Studio/premium-mcps)!`
);
} else {
await postDiscord(
`## \ud83c\udf89 New Sponsor!\n\n` +
`**${sponsor}** just joined as a **${tierName}** sponsor! Welcome to the AnkleBreaker Studio family! \u2764\ufe0f\n\n` +
`Thank you for supporting our MCP tools and open-source projects! \ud83d\ude80\n\n` +
`> Don't forget to claim your **Private MCP Sponsor** Discord role in the [premium-mcps repo](https://github.com/AnkleBreaker-Studio/premium-mcps)!`
);
}
}
} else if (action === 'tier_changed') {
try {
await github.rest.teams.removeMembershipForUserInOrg({ org, team_slug: teamSlug, username: sponsor });
} catch (error) { console.log(`Note: ${sponsor} may not have been in team`); }
}
}
if (action === 'cancelled' || action === 'pending_cancellation') {
try {
await github.rest.teams.removeMembershipForUserInOrg({ org, team_slug: teamSlug, username: sponsor });
} catch (error) { console.log(`Note: ${sponsor} may not have been in team`); }
}