Auto Update Wechat official account #152
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: Auto Update Wechat official account | |
on: | |
push: | |
branches: [ main ] | |
paths: | |
- '.github/workflows/AutoUpdateWeChat.yml' | |
- 'scripts/spider_wechat_account.py' | |
- 'scripts/args.yaml' | |
schedule: | |
- cron: '0 14 * * 5' # 22点运行 14 + 8 | |
env: | |
REPO_SSH: [email protected]:SWHL/AI-Competition-Collections.git | |
USER_NAME: SWHL | |
USER_EMAIL: [email protected] | |
CLONE_DIR: AI-Competition-Collections | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set SSH Environment | |
env: | |
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }} | |
run: | | |
mkdir -p ~/.ssh/ | |
echo "$DEPLOY_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
chmod 700 ~/.ssh && chmod 600 ~/.ssh/* | |
- name: Spider WeChat Account | |
env: | |
WECHAT_COOKIE: ${{ secrets.WECHAT_COOKIE }} | |
WECHAT_TOKEN: ${{ secrets.WECHAT_TOKEN }} | |
id: spider | |
run: | | |
pip install fake_useragent requests | |
git clone $REPO_SSH ${CLONE_DIR} | |
cd ${CLONE_DIR}/scripts | |
output=$(python spider_wechat_account.py --cookie "${WECHAT_COOKIE}" --token ${WECHAT_TOKEN}) | |
echo "is_content=${output}" >> ${GITHUB_OUTPUT} | |
- name: Update Repo. | |
if: steps.spider.outputs.is_content == 1 # 说明有更新 | |
run: | | |
cd ${CLONE_DIR} | |
git config --global user.name $USER_NAME | |
git config --global user.email $USER_EMAIL | |
git remote remove origin | |
git remote add origin $REPO_SSH | |
git add -u | |
git commit -m 'Actions auto update' && git push -f origin ${SUBMMIT_BRANCH} || echo "No changes to commit" |