Skip to content

Commit 2c2ce56

Browse files
committed
test validation
1 parent 9a99fa9 commit 2c2ce56

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/validate-structure.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,28 @@ jobs:
2626
run: cp .github/scripts/validate-structure.js "$RUNNER_TEMP/validate-structure.js"
2727

2828
- name: Fetch pull request head
29+
id: fetch_head
2930
env:
30-
PR_REMOTE_URL: https://x-access-token:${{ github.token }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git
31+
PR_REMOTE_URL: https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git
3132
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
3233
run: |
3334
git remote remove pr >/dev/null 2>&1 || true
3435
git remote add pr "$PR_REMOTE_URL"
35-
git fetch pr "$PR_HEAD_REF":pr-head --depth=1
36-
git checkout pr-head
36+
if git fetch pr "$PR_HEAD_REF":pr-head --depth=1; then
37+
git checkout pr-head
38+
echo "fetched=true" >> "$GITHUB_OUTPUT"
39+
else
40+
echo "::warning::Unable to fetch fork repository. Skipping structure validation."
41+
echo "fetched=false" >> "$GITHUB_OUTPUT"
42+
fi
3743
3844
- name: Use Node.js 18
3945
uses: actions/setup-node@v4
4046
with:
4147
node-version: 18
4248

4349
- name: Validate folder layout
50+
if: ${{ steps.fetch_head.outputs.fetched == 'true' }}
4451
id: validate
4552
continue-on-error: true
4653
run: node "$RUNNER_TEMP/validate-structure.js" origin/${{ github.event.pull_request.base.ref }}...HEAD
@@ -59,7 +66,7 @@ jobs:
5966
owner,
6067
repo,
6168
issue_number: pullNumber,
62-
body: `Thank you for your contribution. However, it doesn't comply with our contributing guidelines. As a reminder, the general requirements (as outlined in the [CONTRIBUTING.md file](https://github.com/ServiceNowDevProgram/code-snippets/blob/main/CONTRIBUTING.md)) are the following: follow the folder+subfolder+snippetfolder guidelines and include a README.md file explaining what the code snippet does. Review your contribution against the guidelines and make the necessary adjustments. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.`.trim()
69+
body: `Thank you for your contribution. However, it doesn't comply with our contributing guidelines. As a reminder, the general requirements (as outlined in the [CONTRIBUTING.md file](https://github.com/ServiceNowDevProgram/code-snippets/blob/main/CONTRIBUTING.md)) are the following: follow the folder+subfolder guidelines and include a README.md file explaining what the code snippet does. Review your contribution against the guidelines and make the necessary adjustments. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.`.trim()
6370
});
6471
6572
await github.rest.pulls.update({
@@ -72,4 +79,3 @@ jobs:
7279
- name: Mark job as failed if validation failed
7380
if: ${{ steps.validate.outcome == 'failure' }}
7481
run: exit 1
75-

0 commit comments

Comments
 (0)