Something went wrong. Try again.
POC for a database of flagged users on github
Something went wrong. Try again.
5.8 kB · 159 lines
YAML
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160name: Process Application
on: issues: types: [opened, labeled]
concurrency: group: data-write-application cancel-in-progress: false
permissions: issues: write contents: write
jobs: validate: if: | github.event.action == 'opened' && contains(github.event.issue.labels.*.name, 'apply') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4
- name: Parse issue body id: parse uses: stefanbuck/github-issue-parser@v3 with: template-path: .github/ISSUE_TEMPLATE/apply.yml
- name: Validate application id: validate env: REPOSITORY: ${{ steps.parse.outputs.issueparser_repository }} MAINTAINER: ${{ steps.parse.outputs.issueparser_maintainer }} ISSUE_AUTHOR: ${{ github.event.issue.user.login }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: bash scripts/process-application.sh
- name: Comment (validation failed - author mismatch) if: failure() && steps.validate.outputs.result == 'author_mismatch' uses: actions/github-script@v7 with: script: | await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: '**Application rejected.** Issue author does not match the claimed maintainer username.' }); await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, state: 'closed' });
- name: Comment (already trusted) if: failure() && steps.validate.outputs.result == 'already_trusted' uses: actions/github-script@v7 with: script: | await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: '**Application rejected.** Repository is already in the trusted reporter network.' }); await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, state: 'closed' });
- name: Comment (repo not found) if: failure() && steps.validate.outputs.result == 'repo_not_found' uses: actions/github-script@v7 with: script: | await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: '**Application rejected.** Repository does not exist or is not publicly accessible.' }); await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, state: 'closed' });
- name: Add pending label if: success() uses: actions/github-script@v7 with: script: | await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, labels: ['apply/pending'] }); await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: '**Application validated.** Awaiting maintainer review.\n\nA maintainer will add the `approved` label to approve this application.' });
approve: if: | github.event.action == 'labeled' && github.event.label.name == 'approved' && contains(github.event.issue.labels.*.name, 'apply') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4
- name: Parse issue body id: parse uses: stefanbuck/github-issue-parser@v3 with: template-path: .github/ISSUE_TEMPLATE/apply.yml
- name: Add to trusted repos env: REPOSITORY: ${{ steps.parse.outputs.issueparser_repository }} MAINTAINER: ${{ steps.parse.outputs.issueparser_maintainer }} ISSUE_AUTHOR: ${{ github.event.issue.user.login }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: bash scripts/process-application.sh
- name: Commit data run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add data/trusted-repos.json git commit -m "Add ${{ steps.parse.outputs.issueparser_repository }} to trusted network (via #${{ github.event.issue.number }})" git push
- name: Comment and close uses: actions/github-script@v7 with: script: | await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: '**Application approved!** Repository `${{ steps.parse.outputs.issueparser_repository }}` has been added to the trusted reporter network.\n\nYou can now use the areyouabot action to submit reports.' }); await github.rest.issues.update({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, state: 'closed' });