Skip to content

2cixiazai

2cixiazai #23

Workflow file for this run

name: 2cixiazai
on:
repository_dispatch:
workflow_dispatch:
inputs:
Url:
description: 'Download Url'
required: false
default: 'false'
# watch:
# types: started
env:
FILE_PATH: 'downloads'
jobs:
build:
runs-on: ubuntu-latest
if: github.event.repository.owner.id == github.event.sender.id
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: Aria2 Install
run: sudo apt install -y aria2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: install prerequisites
run: |
python -m pip install --upgrade pip wheel
pip install install lk21==1.5.61 pymongo pymongo[srv] pymongo[tls] certifi
# - name: Get Download Url
# id: geturl
# run: |
# url=$(python task.py --con="${{ secrets.DB_CONNECT }}" --isnow=1)
# echo "::set-output name=fileurl::$url"
# - name: Downloading
# id: downloading
# if: steps.geturl.outputs.fileurl != 'None' && !cancelled()
# run: |
# url="${{ steps.geturl.outputs.fileurl }}"
# filename=${url##*##}
# download=${url%##*}
# downloadurl=$(python get_url.py --url="$download")
# echo "::set-output name=path::downloads/$filename"
# echo "::set-output name=filename::$filename"
# aria2c --conf $GITHUB_WORKSPACE/aria2.conf --seed-time=0 -d downloads -c $downloadurl -o $filename
# size=$(ls -l downloads/$filename | awk '{print $5}' )
# echo "::set-output name=size::$size"
- name: Downloading
id: downloading
run: |
python download.py --con="${{ secrets.DB_CONNECT }}" --isnow="1"
filename=$(ls downloads | head -n1)
echo "::set-output name=path::downloads/$filename"
echo "::set-output name=filename::$filename"
size=$(ls -l downloads/$filename | awk '{print $5}' )
echo "::set-output name=size::$size"
- uses: ykxVK8yL5L/[email protected]
id: web3
if: steps.downloading.outputs.filename != '' && !cancelled()
with:
web3_token: ${{ secrets.WEB3_STORAGE_TOKEN }}
path_to_add: "${{ steps.downloading.outputs.path }}"
file_name: "${{ steps.downloading.outputs.filename }}"
wrap_with_directory: true
- name: Save Data
id: database
if: steps.downloading.outputs.filename != '' && !cancelled()
run: |
python mongodb.py --con="${{ secrets.DB_CONNECT }}" --name="${{ steps.downloading.outputs.filename }}" --size="${{ steps.downloading.outputs.size }}" --cid="${{ steps.web3.outputs.cid }}"
echo "::set-output name=status::ok"
- name: 开启新的下载任务
uses: benc-uk/workflow-dispatch@v1
if: steps.downloading.outputs.filename != '' && !cancelled() && !failure()
with:
workflow: 2cixiazai.yaml
ref: main
token: ${{ secrets.TOKEN }}
ctor: v2-share
- name: Notify upload info to mqtt broker
if: steps.database.outputs.status != '' && !cancelled()
uses: juhrlass/mqtt-action@master
with:
protocol: mqtt
host: broker-cn.emqx.io
port: 1883
topic: ${{ secrets.SYNC_TOPIC }}
message: 'ok'
username: ''
password: ''
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 0
keep_minimum_runs: 0