Delete shaders/hypnodroid2 directory #28
Workflow file for this run
This file contains 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: Conditional PR Merge with Directory Scope Check | |
on: | |
pull_request_review: | |
types: [submitted] | |
pull_request_target: | |
types: [opened, synchronize, reopened] | |
jobs: | |
directory-scope-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
- name: Ensure changes are scoped to user's directory | |
id: scope_check | |
uses: actions/github-script@v7.0.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const username = context.payload.pull_request.user.login; | |
const filesChanged = await github.rest.pulls.listFiles({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.pull_request.number | |
}); | |
const isValidScope = filesChanged.data.every(file => { | |
const inUserFolder = file.filename.startsWith(`shaders/${username}/`); | |
const isFragmentShader = file.filename.endsWith('.frag'); | |
return inUserFolder && isFragmentShader; | |
}); | |
core.setOutput('valid_scope', isValidScope); // Correct way to set output | |
if (!isValidScope) { | |
console.log("PR contains changes outside the user's specific directory."); | |
} else { | |
console.log("All changes are within the user's specific directory."); | |
} | |
- name: Merge PR if only user directory is changed and checks passed | |
if: steps.scope_check.outputs.valid_scope == 'true' | |
uses: actions/github-script@v7.0.1 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
github.rest.pulls.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.pull_request.number, | |
merge_method: 'squash' | |
}); |