-
Notifications
You must be signed in to change notification settings - Fork 7
53 lines (47 loc) · 2.21 KB
/
submit-shader.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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/[email protected]
- name: Ensure changes are scoped to user's directory
id: scope_check
uses: actions/[email protected]
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.toString());
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/[email protected]
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'
});