fix: fetch enhancement script from base branch if missing in PR

When PRs come from forks that were created before the enhance-cve-fields.py
script was added, the workflow fails because the script doesn't exist in
the PR branch. This fix checks if the script exists and fetches it from
the base branch if needed.

Fixes https://github.com/projectdiscovery/nuclei-templates/actions/runs/20262489530/job/58177646081
This commit is contained in:
Prince Chaddha
2025-12-16 14:49:00 +05:30
parent 882ebf8e4a
commit bdd5d8a0b5

View File

@@ -41,6 +41,12 @@ jobs:
- name: Enhance CVE templates
if: steps.files.outputs.changed == 'true'
run: |
# Fetch enhancement script from base branch if not present in PR branch
if [ ! -f ".github/scripts/enhance-cve-fields.py" ]; then
echo "Enhancement script not found in PR branch, fetching from base branch..."
git fetch origin ${{ github.event.pull_request.base.ref }}
git checkout origin/${{ github.event.pull_request.base.ref }} -- .github/scripts/enhance-cve-fields.py
fi
while read file; do
[ -f "$file" ] && python .github/scripts/enhance-cve-fields.py "$file"
done < /tmp/cve_files.txt