forked from storacha/add-to-web3
-
Notifications
You must be signed in to change notification settings - Fork 8
108 lines (91 loc) · 3.24 KB
/
ipfs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: 3Upload file to ipfs
on:
repository_dispatch:
# schedule:
# - cron: "30 * * * *"
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 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="0")
# 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="0"
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: aquiladev/[email protected]
id: web3
if: steps.downloading.outputs.filename != '' && !cancelled()
with:
path: downloads/
timeout: 6000000
- 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.hash }}"
echo "::set-output name=status::ok"
- 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