Fix: Pre-create Playwright screenshot directory to prevent ENOENT errors #2248
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: Content Moderation | |
| on: | |
| issues: | |
| types: [opened] | |
| pull_request: | |
| types: [opened] | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| moderate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| env: | |
| BLOCKED_USERS: ${{ vars.BLOCKED_USERS || '' }} | |
| with: | |
| script: | | |
| const blocklist = (process.env.BLOCKED_USERS || '').split(',').map(u => u.trim()).filter(u => u); | |
| core.info(`Blocklist: ${blocklist.join(', ') || 'empty'}`); | |
| if (!blocklist.length) return; | |
| let user, number, commentId; | |
| if (context.eventName === 'issues') { | |
| user = context.payload.issue.user.login; | |
| number = context.payload.issue.number; | |
| } else if (context.eventName === 'pull_request') { | |
| user = context.payload.pull_request.user.login; | |
| number = context.payload.pull_request.number; | |
| } else if (context.eventName === 'issue_comment') { | |
| user = context.payload.comment.user.login; | |
| number = context.payload.issue.number; | |
| commentId = context.payload.comment.id; | |
| } | |
| core.info(`Checking user: ${user}`); | |
| if (!blocklist.includes(user)) { | |
| core.info(`User ${user} not in blocklist, skipping`); | |
| return; | |
| } | |
| core.info(`User ${user} is blocked, taking action`); | |
| if (commentId) { | |
| core.info(`Minimizing comment ${commentId}`); | |
| const comment = await github.rest.issues.getComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: commentId | |
| }); | |
| const nodeId = comment.data.node_id; | |
| await github.graphql( | |
| ` | |
| mutation($commentId: ID!) { | |
| minimizeComment(input: {subjectId: $commentId, classifier: SPAM}) { | |
| minimizedComment { | |
| isMinimized | |
| } | |
| } | |
| } | |
| `, | |
| { commentId: nodeId } | |
| ); | |
| } else if (context.eventName === 'issues') { | |
| core.info(`Closing issue #${number}`); | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: number, | |
| state: 'closed', | |
| state_reason: 'not_planned' | |
| }); | |
| } else if (context.eventName === 'pull_request') { | |
| core.info(`Closing PR #${number}`); | |
| await github.rest.pulls.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: number, | |
| state: 'closed' | |
| }); | |
| } |