Bug Bounty Program | Lark #62
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 🚮 Remove program entry | |
| on: | |
| issues: | |
| types: [labeled] | |
| jobs: | |
| process: | |
| if: github.event.label.name == 'program-removal' | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: program-data-mutation | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| token: ${{ secrets.BOT_TOKEN }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: pip install -r lib/requirements.txt | |
| - name: Process removal | |
| id: process | |
| env: | |
| ISSUE_BODY: ${{ github.event.issue.body }} | |
| ISSUE_NUMBER: ${{ github.event.issue.number }} | |
| ISSUE_AUTHOR: ${{ github.event.issue.user.login }} | |
| run: python lib/process-removal.py | |
| - name: Create PR | |
| if: steps.process.outputs.result == 'removed' | |
| env: | |
| GH_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| BRANCH: ${{ steps.process.outputs.branch }} | |
| COMPANY: ${{ steps.process.outputs.company }} | |
| PR_BODY: ${{ steps.process.outputs.pr_body }} | |
| run: | | |
| # Resolve author info (so they get contributor credit), fallback to ghost | |
| AUTHOR_LOGIN="${{ github.event.issue.user.login }}" | |
| AUTHOR_LOGIN="${AUTHOR_LOGIN:-ghost}" | |
| AUTHOR_API=$(gh api "/users/${AUTHOR_LOGIN}" 2>/dev/null || echo '{}') | |
| AUTHOR_NAME=$(echo "$AUTHOR_API" | jq -r '.name // empty') | |
| AUTHOR_NAME="${AUTHOR_NAME//[<>]/}" | |
| AUTHOR_NAME="${AUTHOR_NAME:-$AUTHOR_LOGIN}" | |
| AUTHOR_EMAIL=$(echo "$AUTHOR_API" | jq -r '.email // empty') | |
| if [ -z "$AUTHOR_EMAIL" ]; then | |
| AUTHOR_ID=$(echo "$AUTHOR_API" | jq -r '.id // empty') | |
| if [ -n "$AUTHOR_ID" ]; then | |
| AUTHOR_EMAIL="${AUTHOR_ID}+${AUTHOR_LOGIN}@users.noreply.github.com" | |
| else | |
| AUTHOR_EMAIL="${AUTHOR_LOGIN}@users.noreply.github.com" | |
| fi | |
| fi | |
| # Bot is committer and co-author, issue opener is author | |
| git config user.name "Liss-Bot" | |
| git config user.email "alicia-gh-bot@mail.as93.net" | |
| git checkout -b "$BRANCH" | |
| git add independent-programs.yml | |
| git commit \ | |
| --author="$AUTHOR_NAME <$AUTHOR_EMAIL>" \ | |
| -m "$(printf 'Remove program: %s\n\nCo-Authored-By: Liss-Bot <alicia-gh-bot@mail.as93.net>' "$COMPANY")" | |
| git push -u origin "$BRANCH" --force | |
| if gh pr view "$BRANCH" --json number -q .number >/dev/null 2>&1; then | |
| gh pr edit "$BRANCH" --title "Remove program: $COMPANY" --body "$PR_BODY" | |
| else | |
| gh pr create \ | |
| --head "$BRANCH" \ | |
| --base main \ | |
| --title "Remove program: $COMPANY" \ | |
| --body "$PR_BODY" | |
| fi | |
| - name: Comment on issue (removed) | |
| if: steps.process.outputs.result == 'removed' | |
| env: | |
| GH_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| ISSUE_NUMBER: ${{ github.event.issue.number }} | |
| BRANCH: ${{ steps.process.outputs.branch }} | |
| COMPANY: ${{ steps.process.outputs.company }} | |
| run: | | |
| PR_URL=$(gh pr view "$BRANCH" --json url -q .url) | |
| AUTHOR_LOGIN="${{ github.event.issue.user.login }}" | |
| gh issue comment "$ISSUE_NUMBER" \ | |
| --body "Hey @${AUTHOR_LOGIN}, thanks for your suggestion! I've opened a PR to remove ${COMPANY} in ${PR_URL}. Please take a moment to review it, so that we can get it merged! Thank you 😊" | |
| - name: Comment on issue (other) | |
| if: steps.process.outputs.result != 'removed' && steps.process.outputs.result != '' | |
| env: | |
| GH_TOKEN: ${{ secrets.BOT_TOKEN }} | |
| ISSUE_NUMBER: ${{ github.event.issue.number }} | |
| COMMENT: ${{ steps.process.outputs.comment }} | |
| run: | | |
| gh issue comment "$ISSUE_NUMBER" --body "$COMMENT" |