Skip to content

Add new GlideQuery Conditional Field Selection snippet and update git ignore #7

Add new GlideQuery Conditional Field Selection snippet and update git ignore

Add new GlideQuery Conditional Field Selection snippet and update git ignore #7

name: Validate Folder Structure
on:
pull_request_target:
branches:
- main
permissions:
contents: read
pull-requests: write
concurrency:
group: folder-structure-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
structure:
runs-on: ubuntu-latest
steps:
- name: Checkout base repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cache validation script
run: cp .github/scripts/validate-structure.js "$RUNNER_TEMP/validate-structure.js"
- name: Fetch pull request head
env:
PR_REMOTE_URL: https://x-access-token:${{ github.token }}@github.com/${{ github.event.pull_request.head.repo.full_name }}.git
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
git remote remove pr >/dev/null 2>&1 || true
git remote add pr "$PR_REMOTE_URL"
git fetch pr "$PR_HEAD_REF":pr-head --depth=1
git checkout pr-head
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: 18
- name: Validate folder layout
id: validate
continue-on-error: true
run: node "$RUNNER_TEMP/validate-structure.js" origin/${{ github.event.pull_request.base.ref }}...HEAD
- name: Close pull request on failure
if: ${{ steps.validate.outcome == 'failure' }}
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const pullNumber = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
await github.rest.issues.createComment({
owner,
repo,
issue_number: pullNumber,
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()
});
await github.rest.pulls.update({
owner,
repo,
pull_number: pullNumber,
state: 'closed'
});
- name: Mark job as failed if validation failed
if: ${{ steps.validate.outcome == 'failure' }}
run: exit 1