mirror of
https://github.com/fabriziosalmi/patterns.git
synced 2025-12-29 16:15:12 +00:00
Update update_patterns.yml
This commit is contained in:
35
.github/workflows/update_patterns.yml
vendored
35
.github/workflows/update_patterns.yml
vendored
@@ -10,17 +10,17 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: 🚚 Checkout Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Full history to avoid shallow clone issues
|
fetch-depth: 0 # Full history to avoid shallow clone issues
|
||||||
|
|
||||||
- name: Set Up Python
|
- name: ⚙️ Set Up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.11'
|
python-version: '3.11'
|
||||||
|
|
||||||
- name: Cache Python Packages
|
- name: 📦 Cache Python Packages
|
||||||
id: cache-pip
|
id: cache-pip
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
@@ -29,51 +29,50 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-pip-
|
${{ runner.os }}-pip-
|
||||||
|
|
||||||
- name: Install Dependencies
|
- name: 📥 Install Dependencies
|
||||||
if: steps.cache-pip.outputs.cache-hit != 'true'
|
if: steps.cache-pip.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install requests beautifulsoup4
|
pip install -r requirements.txt
|
||||||
continue-on-error: false # Fail the workflow if dependencies fail to install
|
continue-on-error: false # Fail the workflow if dependencies fail to install
|
||||||
|
|
||||||
- name: Run OWASP Scraper
|
- name: 🕷️ Run OWASP Scraper
|
||||||
run: |
|
run: |
|
||||||
python owasp.py
|
python owasp.py
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
|
|
||||||
- name: Convert OWASP to Caddy WAF
|
- name: 🔄 Convert OWASP to Caddy WAF
|
||||||
run: |
|
run: |
|
||||||
python owasp2caddy.py
|
python owasp2caddy.py
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
|
|
||||||
- name: Convert OWASP to Nginx WAF
|
- name: 🔄 Convert OWASP to Nginx WAF
|
||||||
run: |
|
run: |
|
||||||
python owasp2nginx.py
|
python owasp2nginx.py
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
|
|
||||||
- name: Check for Changes
|
- name: 🔍 Check for Changes
|
||||||
id: git-check
|
id: git-check
|
||||||
run: |
|
run: |
|
||||||
git diff --quiet waf_patterns || echo "changes=true" >> $GITHUB_ENV
|
git diff --quiet waf_patterns || echo "changes=true" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Commit and Push Changes
|
- name: 🚀 Commit and Push Changes
|
||||||
if: env.changes == 'true'
|
if: env.changes == 'true'
|
||||||
run: |
|
run: |
|
||||||
git config user.name "github-actions[bot]"
|
git config user.name "github-actions[bot]"
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
git add waf_patterns/caddy/*.conf
|
git add waf_patterns/caddy/*.conf waf_patterns/nginx/*.conf
|
||||||
git add waf_patterns/nginx/*.conf
|
git commit -m "Automated update: OWASP CRS to Caddy and Nginx WAF rules [$(date)]"
|
||||||
git commit -m "Automated update: OWASP CRS to Caddy and NGinx WAF rules [$(date)]"
|
|
||||||
git push
|
git push
|
||||||
continue-on-error: true # Allow workflow to continue even if no changes
|
continue-on-error: true # Continue even if no changes are made
|
||||||
|
|
||||||
- name: Cleanup Cache (Optional)
|
- name: 🧹 Cleanup Cache (Optional)
|
||||||
run: |
|
run: |
|
||||||
rm -rf ~/.cache/pip
|
rm -rf ~/.cache/pip
|
||||||
if: always() # Run this step even if previous steps fail
|
if: always() # Run this step even if previous steps fail
|
||||||
|
|
||||||
- name: Notify on Failure (Optional)
|
- name: 🚨 Notify on Failure (Optional)
|
||||||
if: failure()
|
if: failure()
|
||||||
run: |
|
run: |
|
||||||
echo "Workflow failed. Notify via Slack or Email."
|
echo "🚨 Workflow failed! Please investigate."
|
||||||
# Add Slack webhook or email notification here
|
# Slack or email notification logic (add webhook or SMTP integration here)
|
||||||
|
|||||||
Reference in New Issue
Block a user