first upload #1
This file contains hidden or 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: Update pluginmaster | |
| on: | |
| push: | |
| branches: [ main ] | |
| jobs: | |
| update-cn-json: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.ACTION_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Create modification script | |
| run: | | |
| cat > modify_json.py << EOF | |
| import json | |
| import re | |
| with open('pluginmaster.json', 'r', encoding='utf-8') as f: | |
| original_data = json.load(f) | |
| def replace_urls(obj): | |
| if isinstance(obj, dict): | |
| for key, value in obj.items(): | |
| if isinstance(value, str): | |
| obj[key] = re.sub( | |
| r'raw\.githubusercontent\.com' | |
| value | |
| ) | |
| else: | |
| replace_urls(value) | |
| elif isinstance(obj, list): | |
| for item in obj: | |
| replace_urls(item) | |
| replace_urls(original_data) | |
| EOF | |
| - name: Run modification script | |
| run: python modify_json.py | |
| - name: Commit and push changes | |
| run: | | |
| git config --global user.email "action@github.com" | |
| git config --global user.name "GitHub Action" | |
| git diff --staged --quiet || git commit -m "Update pluginmaster-cn.json" | |
| git push |