an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
ci(contributor role): let the role be granted by hand, for people without a PR
chaitanyagiri6248293a7cd9
diff --git a/.github/workflows/contributor-role.yml b/.github/workflows/contributor-role.ymlindex 5bb36479..f675b357 100644--- a/.github/workflows/contributor-role.yml+++ b/.github/workflows/contributor-role.yml@@ -1,21 +1,35 @@-# Grants the Discord "employee of the month" role when a PR is merged.+# Grants the Discord "employee of the month" role.+#+# Two ways in:+# 1. Automatically, when a pull request whose body contains "Discord: handle"+# is merged.+# 2. By hand, from the Actions tab or `gh workflow run`, with a list of+# handles. That is for people who earned it without a pull request, or who+# gave their handle in a discussion comment instead of a PR body.## pull_request_target is required so the job can see repo secrets for PRs opened# from forks. It deliberately does NOT check out the PR's code — the only thing# read from the pull request is its body text, and that arrives via an env var so-# it is never interpolated into the shell.+# it is never interpolated into the shell. The manual input is handled the same+# way, and every handle is checked against a strict pattern before it is used.name: contributor roleon:pull_request_target:types: [closed]+ workflow_dispatch:+ inputs:+ handles:+ description: 'Discord usernames, separated by spaces or commas'+ required: true+ type: stringpermissions:contents: readjobs:grant:- if: github.event.pull_request.merged == true+ if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == trueruns-on: ubuntu-lateststeps:- name: grant "employee of the month"@@ -25,6 +39,8 @@ jobs:ROLE_ID: "1539474540298764308"PR_BODY: ${{ github.event.pull_request.body }}PR_AUTHOR: ${{ github.event.pull_request.user.login }}+ INPUT_HANDLES: ${{ inputs.handles }}+ EVENT: ${{ github.event_name }}run: |set -euo pipefailAPI=https://discord.com/api/v10@@ -33,33 +49,49 @@ jobs:echo "DISCORD_BOT_TOKEN is not set — nothing to do."; exit 0fi- # "Discord: someone" anywhere in the PR body. Optional by design.- HANDLE=$(printf '%s' "${PR_BODY:-}" \- | grep -iEo 'Discord:[[:space:]]*[A-Za-z0-9._]+' \- | head -1 | sed -E 's/.*:[[:space:]]*//' || true)-- if [ -z "$HANDLE" ]; then- echo "No Discord handle in the PR body from @$PR_AUTHOR — skipping (this is fine)."; exit 0+ if [ "$EVENT" = "workflow_dispatch" ]; then+ # Commas and spaces both separate. Anything that is not a legal+ # Discord username is dropped before it reaches a command.+ HANDLES=$(printf '%s' "${INPUT_HANDLES:-}" | tr ',' ' ' | tr -s '[:space:]' '\n' \+ | grep -E '^[A-Za-z0-9._]+$' || true)+ if [ -z "$HANDLES" ]; then+ echo "No usable handle in the input — nothing to do."; exit 1+ fi+ else+ # "Discord: someone" anywhere in the PR body. Optional by design.+ HANDLES=$(printf '%s' "${PR_BODY:-}" \+ | grep -iEo 'Discord:[[:space:]]*[A-Za-z0-9._]+' \+ | head -1 | sed -E 's/.*:[[:space:]]*//' || true)+ if [ -z "$HANDLES" ]; then+ echo "No Discord handle in the PR body from @$PR_AUTHOR — skipping (this is fine)."; exit 0+ fifi- echo "Looking up Discord handle: $HANDLE"- Q=$(jq -rn --arg q "$HANDLE" '$q|@uri')- USER_ID=$(curl -sS -H "Authorization: Bot $BOT_TOKEN" \- "$API/guilds/$GUILD_ID/members/search?query=$Q&limit=10" \- | jq -r --arg h "$HANDLE" \- '[.[] | select((.user.username // "" | ascii_downcase) == ($h | ascii_downcase))][0].user.id // empty')+ failed=0+ while IFS= read -r HANDLE; do+ [ -n "$HANDLE" ] || continue+ echo "Looking up Discord handle: $HANDLE"- if [ -z "$USER_ID" ]; then- echo "'$HANDLE' is not a member of the server yet — skipping."- echo "They can join at https://discord.gg/SEDzP5ZPk5 and we'll grant it on their next PR."- exit 0- fi+ Q=$(jq -rn --arg q "$HANDLE" '$q|@uri')+ USER_ID=$(curl -sS -H "Authorization: Bot $BOT_TOKEN" \+ "$API/guilds/$GUILD_ID/members/search?query=$Q&limit=10" \+ | jq -r --arg h "$HANDLE" \+ '[.[] | select((.user.username // "" | ascii_downcase) == ($h | ascii_downcase))][0].user.id // empty')++ if [ -z "$USER_ID" ]; then+ echo "'$HANDLE' is not a member of the server yet — skipping."+ echo "They can join at https://discord.gg/SEDzP5ZPk5 and we'll grant it on their next PR."+ continue+ fi++ code=$(curl -sS -o /dev/null -w '%{http_code}' -X PUT \+ -H "Authorization: Bot $BOT_TOKEN" -H 'Content-Length: 0' \+ "$API/guilds/$GUILD_ID/members/$USER_ID/roles/$ROLE_ID")- code=$(curl -sS -o /dev/null -w '%{http_code}' -X PUT \- -H "Authorization: Bot $BOT_TOKEN" -H 'Content-Length: 0' \- "$API/guilds/$GUILD_ID/members/$USER_ID/roles/$ROLE_ID")+ case "$code" in+ 204) echo "Granted 'employee of the month' to $HANDLE ($USER_ID)." ;;+ *) echo "Discord returned HTTP $code for $HANDLE — role not granted."; failed=1 ;;+ esac+ done <<< "$HANDLES"- case "$code" in- 204) echo "Granted 'employee of the month' to $HANDLE ($USER_ID)." ;;- *) echo "Discord returned HTTP $code — role not granted."; exit 1 ;;- esac+ exit "$failed"