Skip to content

Update ACL4SSR_Online_Full_WithIcon.yaml #2

Update ACL4SSR_Online_Full_WithIcon.yaml

Update ACL4SSR_Online_Full_WithIcon.yaml #2

Workflow file for this run

name: Convert Icon URL to Base64
on:
push:
paths:
- yaml/ACL4SSR_Online_Full_WithIcon.yaml
jobs:
convert-icons:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml requests
- name: Convert icon URLs to Base64 and modify YAML
run: |
python - <<EOF
import yaml
import requests
import base64
input_file = 'yaml/ACL4SSR_Online_Full_WithIcon.yaml'
output_file = 'yaml/ACL4SSR_Online_Full_WithBase64Icon.yaml'
with open(input_file, 'r', encoding='utf-8') as file:
data = yaml.safe_load(file)
def url_to_base64(url):
response = requests.get(url)
if response.status_code == 200:
img_type = url.split('.')[-1]
base64_str = base64.b64encode(response.content).decode('utf-8')
return f"data:image/{img_type};base64,{base64_str}"
else:
return url
for group in data.get('proxy-groups', []):
if 'icon' in group:
group['icon'] = url_to_base64(group['icon'])
with open(output_file, 'w', encoding='utf-8') as file:
yaml.dump(data, file, allow_unicode=True)
print(f"Conversion completed: {output_file}")
EOF
- name: Commit and Push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add yaml/ACL4SSR_Online_Full_WithBase64Icon.yaml
git commit -m "Converted image URL to base64 in ACL4SSR_Online_Full_WithBase64Icon.yaml"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}