[NSH-2026] Adds two sponsors #6
Workflow file for this run
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: Block sponsor asset changes | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| jobs: | |
| guard: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Detect changes under static/img/sponsors | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| token: ${{ github.token }} | |
| list-files: json | |
| filters: | | |
| sponsors: | |
| - 'static/img/sponsors/**' | |
| - name: Comment and fail if sponsors directory changed | |
| if: steps.changes.outputs.sponsors == 'true' | |
| uses: actions/github-script@v7 | |
| env: | |
| SPONSORS_FILES_JSON: ${{ steps.changes.outputs.sponsors_files }} | |
| with: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const issue_number = context.payload.pull_request.number; | |
| const marker = "<!-- sponsors-dir-guard -->"; | |
| let files = []; | |
| try { | |
| files = JSON.parse(process.env.SPONSORS_FILES_JSON || "[]"); | |
| } catch (e) { | |
| files = []; | |
| } | |
| const fileList = files.length | |
| ? files.map(f => `- \`${f}\``).join("\n") | |
| : "- _(Unable to enumerate files, but changes were detected)_"; | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, | |
| repo, | |
| issue_number, | |
| per_page: 100, | |
| }); | |
| const alreadyCommented = comments.some(c => (c.body || "").includes(marker)); | |
| if (!alreadyCommented) { | |
| const body = [ | |
| "🚫 **Blocked: sponsor assets directory change detected**", | |
| "", | |
| "This PR adds or modifies files under `static/img/sponsors/`.", | |
| "", | |
| "**These files should not be added or changed.**", | |
| "", | |
| "Please use the `assets/sponsors/*` directory instead.", | |
| "", | |
| "**Affected files:**", | |
| fileList, | |
| "", | |
| marker | |
| ].join("\n"); | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number, | |
| body, | |
| }); | |
| } else { | |
| core.info("Sponsor directory warning comment already exists; skipping comment creation."); | |
| } | |
| core.setFailed("Changes detected under static/img/sponsors/. Revert these changes to pass."); |