INIT #10
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: 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: | |
if u in j and u in us and not us[u]['enable'] and (j[u][0] != p or j[u][1] != s): | |
us[u]['enable'] = True | |
us[u].pop('status') | |
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 |