Files
oak-gpui/.github/workflows/congrats.yml
T
2025-09-11 12:04:09 -04:00

67 lines
2.4 KiB
YAML

name: Congratsbot
on:
push:
branches: [main]
jobs:
check-author:
if: ${{ github.repository_owner == 'zed-industries' }}
runs-on: ubuntu-latest
outputs:
should_congratulate: ${{ steps.check.outputs.should_congratulate }}
steps:
- name: Get PR info and check if author is external
id: check
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha
});
if (prs.length === 0) {
core.setOutput('should_congratulate', 'false');
return;
}
const mergedPR = prs.find(pr => pr.merged_at !== null) || prs[0];
const prAuthor = mergedPR.user.login;
try {
await github.rest.teams.getMembershipForUserInOrg({
org: 'zed-industries',
team_slug: 'staff',
username: prAuthor
});
core.setOutput('should_congratulate', 'false');
} catch (error) {
if (error.status === 404) {
core.setOutput('should_congratulate', 'true');
} else {
console.error(`Error checking team membership: ${error.message}`);
core.setOutput('should_congratulate', 'false');
}
}
congrats:
needs: check-author
if: needs.check-author.outputs.should_congratulate == 'true'
uses: withastro/automation/.github/workflows/congratsbot.yml@main
with:
EMOJIS: 🎉,🎊,🧑‍🚀,🥳,🙌,🚀,🦀,🔥,🚢
COAUTHOR_TEMPLATES: >
[
"Thank you for making Zed better, <names>! In Rust we trust!",
"Successfully moved this PR into main! No lifetime errors here, thanks <names>!",
"Ferris approves! Thanks <names>!",
"Crab rave time! Code from <names> has been oxidized and merged!",
"The borrow checker is happy, and so are we! Welcome to the cargo club, <names>!",
"Crabs can live up to 100 years, but this PR from <names> will live forever in our git history!"
]
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_CONGRATS }}