Skip to content

Commit

Permalink
bugfix: 使用environ传递口令,解决密码中包含特殊字符导致sed出错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
IanSmith123 committed Nov 7, 2020
1 parent df2d37a commit efe7ef3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ jobs:

# Runs a set of commands using the runners shell
- name: Run a multi-line script
env:
SEP_USER_NAME: ${{secrets.SEP_USER_NAME}}
SEP_PASSWORD: ${{secrets.SEP_PASSWORD}}
API_KEY: ${{secrets.API_KEY}}
run: |
python -m pip install --upgrade pip
python -m pip install pytz requests datetime
sed -i "s/PASSWORD/${{ secrets.SEP_PASSWD }}/g" sub.py
sed -i "s/USERNAME/${{ secrets.SEP_USER_NAME }}/g" sub.py
sed -i "s/API_KEY/${{ secrets.API_KEY }}/g" sub.py
python ./sub.py # 去除了debug信息,可以直接输出了
#python ./sub.py >> /dev/null
python ./sub.py
17 changes: 12 additions & 5 deletions sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
mail: [email protected]
license: CC BY-NC-SA 3.0
"""

import os
import pytz
import requests
from time import sleep
from random import randint
from datetime import datetime

user = "USERNAME" # sep账号
passwd = "PASSWORD" # sep密码
api_key = "API_KEY" # server酱的api,填了可以微信通知打卡结果,不填没影响

# 开启debug将会输出打卡填报的数据,关闭debug只会输出打卡成功或者失败,如果使用github actions,请务必设置该选项为False
debug = False

# 全局变量
user = "USERNAME"
passwd = "PASSWORD"
api_key = "API_KEY"

# 如果检测到程序在 github actions 内运行,那么读取环境变量中的登录信息
if os.environ.get('GITHUB_RUN_ID', None):
user = os.environ['SEP_USER_NAME'] # sep账号
passwd = os.environ['SEP_PASSWORD'] # sep密码
api_key = os.environ['API_KEY'] # server酱的api,填了可以微信通知打卡结果,不填没影响


def login(s: requests.Session, username, password):
# r = s.get(
Expand Down

0 comments on commit efe7ef3

Please sign in to comment.