Files
vulhub/.github/workflows/update-vulhub-org.yml
Aaron 63285f61aa
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
first commit
2025-09-06 16:08:15 +08:00

87 lines
2.6 KiB
YAML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Update Vulhub.org Environments
on:
push:
branches:
- master
paths:
- "environments.toml"
workflow_dispatch:
inputs:
dry_run:
description: "Dry run mode (no push to repository)"
type: boolean
default: false
required: false
jobs:
update-environments:
runs-on: ubuntu-latest
steps:
- name: Checkout vulhub repository
uses: actions/checkout@v4
with:
path: vulhub
fetch-depth: 0
- name: Checkout vulhub-org repository
uses: actions/checkout@v4
with:
repository: vulhub/vulhub-org
path: vulhub-org
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Update environments.json
run: |
cd vulhub-org
yarn install --frozen-lockfile
./scripts/update_environments.js -i ../vulhub -o ./lib/environments.json
- name: Upload environments.json
uses: actions/upload-artifact@v4
with:
name: environments.json
path: vulhub-org/lib/environments.json
- name: Check for changes and commit
id: commit
run: |
cd vulhub-org
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add lib/environments.json
git --no-pager diff --staged
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "No changes to commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
git commit -m "Update environments.json from vulhub/environments.toml"
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Push changes
if: steps.commit.outputs.has_changes == 'true' && (github.event_name != 'workflow_dispatch' || !inputs.dry_run)
uses: ad-m/github-push-action@master
with:
repository: vulhub/vulhub-org
github_token: ${{ secrets.VULHUB_ORG_TOKEN }}
branch: main
directory: vulhub-org
- name: Dry run summary
if: github.event_name == 'workflow_dispatch' && inputs.dry_run
run: |
echo "### Dry Run Mode - Changes Not Pushed" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.commit.outputs.has_changes }}" == "true" ]; then
echo "✅ Changes were detected and would have been pushed to the repository" >> $GITHUB_STEP_SUMMARY
else
echo " No changes were detected" >> $GITHUB_STEP_SUMMARY
fi