Skip to content

Commit 4cd2561

Browse files
committed
try that again
1 parent 77e2685 commit 4cd2561

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed
Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,63 @@
11
name: Validate Folder Structure
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
pull-requests: write
11+
812
concurrency:
9-
group: folder-structure-${{ github.head_ref || github.run_id }}
13+
group: folder-structure-${{ github.event.pull_request.number || github.run_id }}
1014
cancel-in-progress: true
1115

1216
jobs:
1317
structure:
1418
runs-on: ubuntu-latest
1519
steps:
16-
- name: Checkout repository
20+
- name: Checkout base repository
1721
uses: actions/checkout@v4
1822
with:
1923
fetch-depth: 0
2024

25+
- name: Cache validation script
26+
run: cp .github/scripts/validate-structure.js "$RUNNER_TEMP/validate-structure.js"
27+
28+
- name: Fetch pull request head
29+
env:
30+
PR_REMOTE_URL: https://x-access-token:${{ github.token }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git
31+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
32+
run: |
33+
git remote remove pr >/dev/null 2>&1 || true
34+
git remote add pr "$PR_REMOTE_URL"
35+
git fetch pr "$PR_HEAD_REF":pr-head --depth=1
36+
git checkout pr-head
37+
2138
- name: Use Node.js 18
2239
uses: actions/setup-node@v4
2340
with:
2441
node-version: 18
2542

2643
- name: Validate folder layout
27-
run: node .github/scripts/validate-structure.js
44+
id: validate
45+
continue-on-error: true
46+
run: node "$RUNNER_TEMP/validate-structure.js" origin/${{ github.event.pull_request.base.ref }}...HEAD
2847

2948
- name: Close pull request on failure
30-
if: ${{ failure() && github.event_name == 'pull_request' }}
49+
if: ${{ steps.validate.outcome == 'failure' }}
3150
uses: actions/github-script@v6
3251
with:
33-
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
github-token: ${{ github.token }}
3453
script: |
3554
await github.rest.pulls.update({
3655
owner: context.repo.owner,
3756
repo: context.repo.repo,
3857
pull_number: context.payload.pull_request.number,
3958
state: 'closed'
4059
});
60+
61+
- name: Mark job as failed if validation failed
62+
if: ${{ steps.validate.outcome == 'failure' }}
63+
run: exit 1

0 commit comments

Comments
 (0)