Add for the first time the extension #3
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: Check nightly-ok label | |
on: | |
pull_request: | |
types: [opened, synchronize, labeled, unlabeled] | |
jobs: | |
check_label: | |
runs-on: ubuntu-latest | |
if: github.repository == 'demisto/content' && github.event.pull_request.head.repo.fork == false | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if files under .gitlab directory are changed | |
id: check-changes | |
run: | | |
CHANGED_FILES=$(git diff --name-only origin/master...origin/${{ github.head_ref || github.ref_name }}) | |
echo "All changed files:" | |
echo "${CHANGED_FILES}" | |
GITLAB_CHANGED_FILES=$( [[ $CHANGED_FILES == *".gitlab/ci"* ]] && echo true || echo false) | |
echo "Files in the .gitlab folder have changed: ${GITLAB_CHANGED_FILES}" | |
echo "gitlab_changed_files=$GITLAB_CHANGED_FILES" >> $GITHUB_OUTPUT | |
if [[ $GITLAB_CHANGED_FILES == true ]]; then | |
echo 'Files under .gitlab folder has changed, Will check if the PR has the `nightly-ok` label.' | |
else | |
echo 'Files in the .gitlab folder have not been changed.' | |
fi | |
- name: Check if PR has the nightly-ok label | |
uses: actions/github-script@v7 | |
id: check-label | |
with: | |
script: | | |
const gitlabChangedFiles = ${{ steps.check-changes.outputs.gitlab_changed_files }}; | |
if(gitlabChangedFiles) { | |
console.log('Files under .gitlab folder has changed, Will check if the PR has the `nightly-ok` label.'); | |
const labels = context.payload.pull_request.labels.map(label => label.name); | |
const hasLabel = labels.includes('nightly-ok'); | |
if (hasLabel) { | |
console.log('All good, the PR has the `nightly-ok` label.'); | |
} else { | |
console.log('PR does not have the `nightly-ok` label. It is required when changing files under the `.gitlab` directory. Please run nightly using the Utils/gitlab_triggers/trigger_content_nightly_build.sh script, check that succeeded, and add the `nightly-ok` label'); | |
process.exit(1); // Exit with failure status if label is missing | |
} | |
} else { | |
console.log('Files in the .gitlab folder have not been changed.'); | |
} |