nuclei-templates/.github/workflows/cve-annotate.yml

60 lines
2.1 KiB
YAML
Raw Normal View History

2023-03-26 18:50:56 +00:00
name: TemplateMan
2021-09-10 12:11:35 +00:00
on:
2021-09-11 08:23:26 +00:00
push:
2021-09-10 12:11:35 +00:00
branches:
2023-01-05 10:56:27 +00:00
- main
2023-03-26 18:50:56 +00:00
pull_request:
2023-01-15 16:05:57 +00:00
paths:
2023-03-26 18:50:56 +00:00
- '**.yaml'
2021-09-10 12:11:35 +00:00
workflow_dispatch:
jobs:
docs:
runs-on: ubuntu-latest
steps:
2023-01-15 16:05:57 +00:00
- uses: actions/checkout@v3
with:
fetch-depth: 0
2021-09-10 12:18:49 +00:00
2023-03-26 18:50:56 +00:00
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-pip
pip3 install pyyaml
2021-09-10 12:11:35 +00:00
2023-03-26 18:50:56 +00:00
- name: Send YAML to endpoint and check response
id: templateman-enhance
2021-09-10 12:11:35 +00:00
run: |
2023-03-26 18:50:56 +00:00
API_ENDPOINT="https://orca-app-65k3t.ondigitalocean.app/enhance?resp_format=plain"
FILENAME="${GITHUB_WORKSPACE}/${{ github.event.pull_request.head.repo.full_name }}/${{ github.event.pull_request.head.ref }}/${{ github.event.pull_request.changed_files }}"
for file in $(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" --diff-filter=AM | grep "\.yaml$"); do
echo "Sending file: $file"
response=$(curl -X POST -H "Content-Type: application/x-yaml" --data-binary "@$file" "$API_ENDPOINT")
if python -c "import yaml, sys; yaml.safe_load(sys.stdin)" <<< "$response"; then
echo "Response is valid YAML, updating file..."
printf "%s\n" "$response" > "$file.tmp"
mv "$file.tmp" "$file"
else
echo "Error: invalid YAML in response for $file"
printf "%s\n" "$response" > "${file}.debug.txt"
exit 1
fi
done
2021-09-10 12:11:35 +00:00
- name: Commit files
2023-03-26 18:50:56 +00:00
if: steps.templateman-enhance.outputs.CHANGES > 0
2021-09-10 12:11:35 +00:00
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
2022-02-27 11:03:05 +00:00
git pull
2023-03-26 18:50:56 +00:00
git add .
git commit -m "Templateman Enhancement [$(date)] :robot:" -a
2021-09-10 12:11:35 +00:00
- name: Push changes
if: steps.cve-annotate.outputs.CHANGES > 0
2021-09-10 12:11:35 +00:00
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
2023-03-26 18:50:56 +00:00
branch: ${{ github.ref }}