Skip to content

.github/workflows/report_demo.yml #51

.github/workflows/report_demo.yml

.github/workflows/report_demo.yml #51

Workflow file for this run

on:
schedule:
- cron: '50 11 * * *' # 每天的19:50执行
jobs:
run_python_script:
runs-on: ubuntu-latest
env:
SEND_EMAIL: ${{ vars.SEND_EMAIL }}
SEND_EMAIL_PASSWORD: ${{ secrets.SEND_EMAIL_PASSWORD }}
SETTINGS: ${{ vars.SETTINGS }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: 3.x
- name: 安装依赖环境
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: 获取yaml文件名
id: get_variables
run: |
WORKFLOW_PATH="${{ github.workflow }}"
WORKFLOW_NAME=$(basename $WORKFLOW_PATH)
WORKFLOW_NAME=${WORKFLOW_NAME/\.yml/}
WORKFLOW_NAME=${WORKFLOW_NAME/.*/}
WORKFLOW_NAME=${WORKFLOW_NAME^^}
echo "WORKFLOW_NAME=$WORKFLOW_NAME" >> $GITHUB_OUTPUT
- name: 运行python脚本
id: python_scripts
run: |
if [ -z "${{ vars.SETTINGS }}" ]; then
echo "没有配置信息,不执行脚本"
echo "::set-output name=code_generated::false"
else
python src/main_tiktok.py ${{ steps.get_variables.outputs.WORKFLOW_NAME }}
echo "::set-output name=code_generated::true"
fi
- name: Commit
if: ${{ steps.python_scripts.outputs.code_generated == 'true' }}
run: |
git config --global user.email github-actions[bot]@users.noreply.github.com
git config --global user.name github-actions[bot]
git add .
git commit -m "更新日常数据" -a
- name: Push changes
if: ${{ steps.python_scripts.outputs.code_generated == 'true' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}
branch: master
force: true