This commit is contained in:
denglihong2007
2025-07-26 18:01:02 +08:00
2 changed files with 58 additions and 44 deletions

View File

@@ -1,26 +1,28 @@
name: Deploy name: Deploy
on: on:
push: push:
branches: [ master ] branches: [ master ]
jobs: jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: '3.10' python-version: '3.10'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install requests pip install requests
pip install pyyaml pip install pyyaml
- name: Run deploy script - name: Run deploy script
env: env:
DEPLOY_URL: ${{ secrets.DEPLOY_URL }} DEPLOY_URL: ${{ secrets.DEPLOY_URL }}
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }} DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
run: | MIRROR_DEPLOY_URL: ${{ secrets.MIRROR_DEPLOY_URL }}
python tools/MakePackage.py MIRROR_DEPLOY_TOKEN: ${{ secrets.MIRROR_DEPLOY_TOKEN }}
python tools/PostPackage.py run: |
python tools/MakePackage.py
python tools/PostPackage.py

View File

@@ -1,18 +1,30 @@
import requests import requests
import os import os
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
zip_path = os.path.join(parent_dir, 'output.zip') zip_path = os.path.join(parent_dir, 'output.zip')
url = os.environ['DEPLOY_URL'] url = os.environ['DEPLOY_URL']
token = os.environ.get('DEPLOY_TOKEN', '') token = os.environ.get('DEPLOY_TOKEN', '')
mirror_url = os.environ['MIRROR_DEPLOY_URL']
with open(zip_path, 'rb') as f: mirror_token = os.environ.get('MIRROR_DEPLOY_TOKEN', '')
r = requests.post(
url, with open(zip_path, 'rb') as f:
files={'file': f}, r = requests.post(
headers={'Authorization': f'Bearer {token}'} url,
) files={'file': f},
headers={'Authorization': f'Bearer {token}'}
print(f"Server responded with status: {r.status_code}") )
print(r.text)
with open(zip_path, 'rb') as f:
mirror_r = requests.post(
mirror_url,
files={'file': f},
headers={'Authorization': f'Bearer {mirror_token}'}
)
print(f"Server responded with status: {r.status_code}")
print(r.text)
print(f"Mirror server responded with status: {mirror_r.status_code}")
print(mirror_r.text)