From 323c1e51241de89a21c344107160cf31c538cff3 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 10 Jun 2023 22:43:11 +0800 Subject: [PATCH] Support add new custom code --- .github/workflows/add.yml | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/add.yml diff --git a/.github/workflows/add.yml b/.github/workflows/add.yml new file mode 100644 index 0000000..be5cf59 --- /dev/null +++ b/.github/workflows/add.yml @@ -0,0 +1,68 @@ +name: Add new custom code + +on: + workflow_dispatch: + inputs: + code_type: + description: 'code type' + required: true + type: choice + options: ['main', 'over'] + code: + description: 'gift code' + required: true + expire: + description: 'expire date, format: 2023-6-10' + required: true + rewards: + description: 'rewards, format: 星琼:60 信用点:1000' + required: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + # 此步骤使用 GitHub 的 https://github.com/actions/checkout + - name: checkout actions + uses: actions/checkout@v3 + + # 设置python环境 + # 此步骤使用 GitHub 的 https://github.com/actions/setup-python + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + + # 安装依赖 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + # 添加 code + - name: Update over code + run: | + python add.py ${{ github.event.inputs.code_type }} ${{ github.event.inputs.code }} ${{ github.event.inputs.expire }} ${{ github.event.inputs.rewards }} + python main.py + + # Auto commit + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + author_name: github-actions[bot] + author_email: github-actions[bot]@users.noreply.github.com + message: ':sparkles: Add new code' + add: | + 'data/custom.json' + + # Auto commit + - name: Commit changes + uses: EndBug/add-and-commit@v9 + with: + author_name: github-actions[bot] + author_email: github-actions[bot]@users.noreply.github.com + push: 'origin remote --force' + new_branch: 'remote' + message: ':sparkles: Update Codes' + add: | + 'data'