forked from yehuailin/ManifestAutoUpdate
-
Notifications
You must be signed in to change notification settings - Fork 1
107 lines (107 loc) · 4.79 KB
/
INIT.yml
File metadata and controls
107 lines (107 loc) · 4.79 KB
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
name: INIT
on:
workflow_dispatch:
inputs:
level:
description: Logging Level
required: true
default: INFO
type: choice
options:
- CRITICAL
- FATAL
- ERROR
- WARNING
- WARN
- INFO
- DEBUG
- NOTSET
args:
description: args
required: false
users:
description: users
required: false
password:
description: password
required: false
ssfn:
description: ssfn
required: false
shared_secret:
description: 2fa
required: false
update:
description: update
type: boolean
required: false
default: false
update_users:
description: update_users
required: false
branches:
- main
concurrency:
group: wait
cancel-in-progress: false
jobs:
init:
runs-on: windows-latest
env:
KEY: ${{ secrets.KEY }}
users: ${{ github.event.inputs.users }}
password: ${{ github.event.inputs.password }}
ssfn: ${{ github.event.inputs.ssfn }}
shared_secret: ${{ github.event.inputs.shared_secret }}
UsersJson: ${{ secrets.UsersJson }}
TwoFactorJson: ${{ secrets.TwoFactorJson }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: recursive
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- run: |
git config --local user.name AutoUpdate[bot]
git config --local user.email AutoUpdate[bot]@users.noreply.github.com
- if: ${{ env.KEY != '' }}
run: python main.py -l ${{ github.event.inputs.level || 'INFO' }} -i -k ${{ secrets.KEY }} -P ${{ github.event.inputs.args }}
- if: ${{ env.KEY == '' }}
run: python main.py -l ${{ github.event.inputs.level || 'INFO' }} -i ${{ github.event.inputs.args }}
- if: ${{ env.users != '' }}
#如果用户存在且enable为false 密码或者ssfn 与新添加的不同这替换并修改enable为true,删除status
run: |
python -c "import os
import json
import itertools
j = json.load(open('data/users.json'))
us = json.load(open('data/userinfo.json'))
for u, p, s in itertools.zip_longest([i or None for i in (os.environ.get('users') or '').split(' ')],[i or None for i in (os.environ.get('password') or '').split(' ')],[i or None for i in (os.environ.get('ssfn') or '').split(' ')]):
if u and p:
if u in j:
if u in us and (j[u][1] != s or j[u][0] != p) and not us[u]['enable']:
us[u]['enable'] = True
us[u].pop('status',None)
j.update({u:[p, s]})
else:
j.update({u:[p, s]})
json.dump(us, open('data/userinfo.json', 'w'))
json.dump(j, open('data/users.json', 'w'))"
#run: python -c "import os;import json;import itertools;j=json.load(open('data/users.json'));j.update({u:[p,s] for u,p,s in itertools.zip_longest([i or None for i in (os.environ.get('users') or '').split(',')],[i or None for i in (os.environ.get('password') or '').split(',')],[i or None for i in (os.environ.get('ssfn') or '').split(',')]) if u});json.dump(j,open('data/users.json','w'))"
- if: ${{ env.shared_secret != '' }}
run: python -c "import os;import json;import itertools;j=json.load(open('data/2fa.json'));j.update({u:f for u,f in itertools.zip_longest([i or None for i in (os.environ.get('users') or '').split(',')],[i or None for i in (os.environ.get('shared_secret') or '').split(',')]) if u});json.dump(j,open('data/2fa.json','w'))"
- if: ${{ env.UsersJson != '' }}
run: python -c "import os;import json;j=json.load(open('data/users.json'));j.update(json.loads(os.environ.get('UsersJson') or '{}'));json.dump(j,open('data/users.json','w'));"
- if: ${{ env.TwoFactorJson != '' }}
run: python -c "import os;import json;j=json.load(open('data/2fa.json'));j.update(json.loads(os.environ.get('TwoFactorJson') or '{}'));json.dump(j,open('data/2fa.json','w'));"
- if: ${{ github.event.inputs.update }}
run: python main.py -l ${{ github.event.inputs.level || 'INFO' }} -k ${{ secrets.KEY }} -t 1 -u -P ${{ github.event.inputs.update_users != '' && format('-U {0}', github.event.inputs.update_users) || '' }} ${{ github.event.inputs.args }}
- if: ${{ env.users != '' || env.shared_secret != '' || env.UsersJson != '' || env.TwoFactorJson != '' || github.event.inputs.update }}
run: python push.py