|
| 1 | +name: Validate Registry Intake |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [opened, edited, reopened] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + issues: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + validate: |
| 13 | + if: contains(github.event.issue.labels.*.name, 'registry-intake') |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Clear previous state labels |
| 17 | + # Kind subtype labels (registry-intake:publish/register/deploy/admin) are |
| 18 | + # applied by the form template itself and are NOT cleared here — they |
| 19 | + # persist for the lifetime of the issue. |
| 20 | + uses: issue-ops/labeler@v4 |
| 21 | + with: |
| 22 | + action: remove |
| 23 | + issue_number: ${{ github.event.issue.number }} |
| 24 | + labels: | |
| 25 | + registry-intake:in-review |
| 26 | + registry-intake:accepted |
| 27 | + registry-intake:rejected |
| 28 | + registry-intake:submitted |
| 29 | + registry-intake:submission-failed |
| 30 | + issueops:validation-error |
| 31 | +
|
| 32 | + - name: Resolve form kind and template |
| 33 | + id: kind |
| 34 | + env: |
| 35 | + LABELS_JSON: ${{ toJSON(github.event.issue.labels) }} |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | + KIND=$(jq -r ' |
| 39 | + .[].name |
| 40 | + | select(startswith("registry-intake:")) |
| 41 | + | sub("^registry-intake:"; "") |
| 42 | + | select(. == "publish" or . == "register" or . == "deploy" or . == "admin") |
| 43 | + ' <<<"$LABELS_JSON" | head -n 1) |
| 44 | + if [ -z "${KIND:-}" ]; then |
| 45 | + echo "::error::Issue has the parent `registry-intake` label but no kind subtype (publish/register/deploy/admin). The form template should set both." |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | + case "$KIND" in |
| 49 | + publish) TEMPLATE=registry-publish.yml ;; |
| 50 | + register) TEMPLATE=registry-register.yml ;; |
| 51 | + deploy) TEMPLATE=registry-deploy.yml ;; |
| 52 | + admin) TEMPLATE=registry-admin.yml ;; |
| 53 | + esac |
| 54 | + echo "kind=$KIND" >> "$GITHUB_OUTPUT" |
| 55 | + echo "template=$TEMPLATE" >> "$GITHUB_OUTPUT" |
| 56 | +
|
| 57 | + - name: Checkout repo (for validator scripts and form templates) |
| 58 | + uses: actions/checkout@v6 |
| 59 | + |
| 60 | + - name: Parse intake form |
| 61 | + id: parse |
| 62 | + uses: issue-ops/parser@v5 |
| 63 | + with: |
| 64 | + body: ${{ github.event.issue.body }} |
| 65 | + issue-form-template: ${{ steps.kind.outputs.template }} |
| 66 | + |
| 67 | + - name: Validate intake form |
| 68 | + id: validate |
| 69 | + uses: issue-ops/validator@v4 |
| 70 | + with: |
| 71 | + issue-form-template: ${{ steps.kind.outputs.template }} |
| 72 | + parsed-issue-body: ${{ steps.parse.outputs.json }} |
| 73 | + add-comment: false |
| 74 | + |
| 75 | + - name: Success → in-review |
| 76 | + if: steps.validate.outputs.result == 'success' |
| 77 | + uses: issue-ops/labeler@v4 |
| 78 | + with: |
| 79 | + action: add |
| 80 | + create: true |
| 81 | + issue_number: ${{ github.event.issue.number }} |
| 82 | + labels: | |
| 83 | + registry-intake:in-review |
| 84 | +
|
| 85 | + - name: Success → comment with quorum hint |
| 86 | + if: steps.validate.outputs.result == 'success' |
| 87 | + env: |
| 88 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + run: | |
| 90 | + gh issue comment "${{ github.event.issue.number }}" -R "${{ github.repository }}" --body \ |
| 91 | + ":zap: Validation passed — this intake is now \`registry-intake:in-review\`. |
| 92 | +
|
| 93 | + **Pilots:** react with :+1: or :-1: on this issue. When you believe the quorum has been reached, comment \`.quorum-check\` to tally votes and either accept or reject. |
| 94 | +
|
| 95 | + The quorum policy for kind=\`${{ steps.kind.outputs.kind }}\` is in [\`.github/registry-quorum.yml\`](https://github.com/${{ github.repository }}/blob/main/.github/registry-quorum.yml)." |
| 96 | +
|
| 97 | + - name: Failure → validation-error label |
| 98 | + if: steps.validate.outputs.result != 'success' |
| 99 | + uses: issue-ops/labeler@v4 |
| 100 | + with: |
| 101 | + action: add |
| 102 | + create: true |
| 103 | + issue_number: ${{ github.event.issue.number }} |
| 104 | + labels: | |
| 105 | + issueops:validation-error |
| 106 | +
|
| 107 | + - name: Failure → comment with rendered errors |
| 108 | + if: steps.validate.outputs.result != 'success' |
| 109 | + env: |
| 110 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + COMMENT_ERRORS: ${{ steps.validate.outputs.errors }} |
| 112 | + run: | |
| 113 | + python3 .github/scripts/render_validation_failure.py | \ |
| 114 | + gh issue comment "${{ github.event.issue.number }}" -R "${{ github.repository }}" --body-file - |
| 115 | +
|
| 116 | + - name: Failure → fail the job |
| 117 | + if: steps.validate.outputs.result != 'success' |
| 118 | + run: | |
| 119 | + echo "::error::Form validation failed. See the issue comment for details." |
| 120 | + exit 1 |
0 commit comments