PikPak转存Aliyun #1
This file contains 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: PikPak转存Aliyun | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
inputs: | |
Folder: | |
description: '保存目录' | |
required: true | |
default: 'PikPak' | |
jobs: | |
Aria2-Aliyun: | |
runs-on: ubuntu-latest | |
services: | |
aliyun: | |
image: messense/aliyundrive-webdav | |
env: | |
REFRESH_TOKEN: '${{ secrets.ALIYUN_REFRESH_TOKEN }}' | |
PORT: 8080 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | |
fetch-depth: 0 | |
- name: 增加可用空间 (删除dotnet, android、haskell、CodeQL) | |
shell: bash | |
run: | | |
sudo rm -rf /usr/share/dotnet | |
sudo rm -rf /usr/local/lib/android | |
sudo rm -rf /opt/ghc | |
sudo rm -rf /opt/hostedtoolcache/CodeQL | |
- name: 检查空间使用情况 | |
run: | | |
echo "Free space:" | |
df -h | |
- name: 安装Aria2 | |
run: sudo apt install -y aria2 | |
- name: 安装Python3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: 安装所需要的Python信赖 | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install install requests | |
- name: 下载 | |
id: downloading | |
run: | | |
mkdir downloads | |
python task.py --projet="${{ secrets.DETA_PROJECT_ID }}" --apikey="${{ secrets.DETA_API_KEY }}" --act="download" | |
filename=$(ls downloads | head -n1) | |
echo "::set-output name=path::downloads/$filename" | |
echo "::set-output name=filename::$filename" | |
echo "::set-output name=taskkey::$taskkey" | |
size=$(ls -l downloads/$filename | awk '{print $5}' ) | |
echo "::set-output name=size::$size" | |
- name: 上传到Aliyun | |
uses: thinkdolabs/curl@v1 | |
if: steps.downloading.outputs.filename != '' && !cancelled() && !failure() | |
with: | |
args: --upload-file ${{ steps.downloading.outputs.path }} http://aliyun:8080/${{ github.event.inputs.Folder}}/${{ steps.downloading.outputs.filename }} | |
- name: 保存数据,删除远程已经下载列表 | |
id: database | |
if: steps.downloading.outputs.filename != '' && !cancelled() && !failure() | |
run: | | |
python task.py --projet="${{ secrets.DETA_PROJECT_ID }}" --apikey="${{ secrets.DETA_API_KEY }}" --taskkey="${{ steps.downloading.outputs.taskkey }}" --act="del" | |
echo "::set-output name=status::ok" | |
- name: 开启新的下载任务 | |
uses: benc-uk/workflow-dispatch@v1 | |
if: steps.downloading.outputs.filename != '' && !cancelled() && !failure() | |
with: | |
workflow: aliyun.yml | |
ref: main | |
- name: 删除旧的上传记录 | |
uses: Mattraks/delete-workflow-runs@v2 | |
with: | |
token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
retain_days: 0 | |
keep_minimum_runs: 0 |