|
| 1 | +name: 下载JM本子(dispatch) |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + JM_ALBUM_IDS: |
| 7 | + type: string |
| 8 | + description: 本子id(多个id用-隔开,如 '123-456-789') |
| 9 | + required: true |
| 10 | + default: '' |
| 11 | + |
| 12 | + ZIP_NAME: |
| 13 | + type: string |
| 14 | + default: 本子.tar.gz |
| 15 | + description: 压缩文件名称 |
| 16 | + required: false |
| 17 | + |
| 18 | + UPLOAD_NAME: |
| 19 | + type: string |
| 20 | + default: 下载完成的本子 |
| 21 | + description: 上传文件名称 |
| 22 | + required: false |
| 23 | + |
| 24 | +# JM_USERNAME: |
| 25 | +# type: string |
| 26 | +# default: '' |
| 27 | +# description: '禁漫帐号(不建议使用,用户名和密码会泄露在日志中。最好用secrets)' |
| 28 | +# required: false |
| 29 | +# |
| 30 | +# JM_PASSWORD: |
| 31 | +# type: string |
| 32 | +# default: '' |
| 33 | +# description: '禁漫密码(不建议使用,用户名和密码会泄露在日志中。最好用secrets)' |
| 34 | +# required: false |
| 35 | + |
| 36 | + |
| 37 | +jobs: |
| 38 | + crawler: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + env: |
| 41 | + # 工作流输入 |
| 42 | + JM_ALBUM_IDS: ${{ github.event.inputs.JM_ALBUM_IDS }} |
| 43 | + JM_USERNAME: ${{ secrets.JM_USERNAME }} |
| 44 | + JM_PASSWORD: ${{ secrets.JM_PASSWORD }} |
| 45 | + ZIP_NAME: ${{ github.event.inputs.ZIP_NAME }} |
| 46 | + UPLOAD_NAME: ${{ github.event.inputs.UPLOAD_NAME }} |
| 47 | +# JM_USERNAME: ${{ github.event.inputs.JM_USERNAME }} |
| 48 | +# JM_PASSWORD: ${{ github.event.inputs.JM_PASSWORD }} |
| 49 | + |
| 50 | + # 固定值 |
| 51 | + JM_DOWNLOAD_DIR: /home/runner/work/jmcomic/download/ |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v3 |
| 55 | + - name: Set up Python 3.11 |
| 56 | + uses: actions/setup-python@v4 |
| 57 | + with: |
| 58 | + python-version: "3.11" |
| 59 | + |
| 60 | + - name: 安装依赖项(pip) |
| 61 | + if: ${{ github.ref != 'refs/heads/dev' }} |
| 62 | + run: | |
| 63 | + python -m pip install --upgrade pip |
| 64 | + pip install jmcomic -i https://pypi.org/project --upgrade |
| 65 | +
|
| 66 | + - name: 安装依赖项(local) |
| 67 | + if: ${{ github.ref == 'refs/heads/dev' }} |
| 68 | + run: | |
| 69 | + python -m pip install --upgrade pip |
| 70 | + pip install commonX -i https://pypi.org/project --upgrade |
| 71 | + pip install -e ./ |
| 72 | +
|
| 73 | + - name: 运行下载脚本 |
| 74 | + continue-on-error: true |
| 75 | + run: | |
| 76 | + cd ./usage/ |
| 77 | + python workflow_download.py |
| 78 | +
|
| 79 | + - name: 压缩文件 |
| 80 | + run: | |
| 81 | + cd $JM_DOWNLOAD_DIR |
| 82 | + tar -zcvf ../$ZIP_NAME ./ |
| 83 | + mv ../$ZIP_NAME . |
| 84 | +
|
| 85 | + - name: 上传结果 |
| 86 | + uses: actions/upload-artifact@v3 |
| 87 | + with: |
| 88 | + name: ${{ env.UPLOAD_NAME }} |
| 89 | + path: ${{ env.JM_DOWNLOAD_DIR }}/${{ env.ZIP_NAME }} |
| 90 | + if-no-files-found: error |
| 91 | + retention-days: 90 |
0 commit comments