├── .gitignore ├── .github └── workflows │ ├── monthly-update.yml │ └── health-report.yml ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | -------------------------------------------------------------------------------- /.github/workflows/monthly-update.yml: -------------------------------------------------------------------------------- 1 | # 防止 GitHub 长时间不 commit 导致 Action 自动停用 2 | name: 'Monthly Update Action' 3 | 4 | on: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: '0 0 1 * *' 8 | 9 | jobs: 10 | main: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | - name: Update 16 | run: | 17 | echo "one month" >> monthly.log 18 | - name: Commit files 19 | run: | 20 | git config --local user.name github-actions[bot] 21 | git config --local user.email github-actions[bot]@users.noreply.github.com 22 | git status 23 | git add monthly.log 24 | git commit -m "Monthly update" 25 | git log 26 | git push 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022-present upupming 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/health-report.yml: -------------------------------------------------------------------------------- 1 | name: 'zhr-action Demo' 2 | 3 | on: 4 | workflow_dispatch: 5 | schedule: 6 | # `0 23 * * *` 表示UTC 23:00,即北京时间7:00打卡(经测试,实际运行时间比设定时间晚几分钟到几十分钟)。 7 | # 可以参考 https://crontab.guru/ 进行配置 8 | - cron: '0 23 * * *' 9 | 10 | jobs: 11 | main: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | fail-fast: false 15 | matrix: 16 | include: 17 | - username: ZJU_USERNAME 18 | password: ZJU_PASSWORD 19 | # 如果出现登录异常,可以配置 ZJU_COOKIE secret,请参考 https://github.com/upupming/zhr-action#%E7%99%BB%E5%BD%95%E5%BC%82%E5%B8%B8 获取 ZJU_COOKIE 的值 20 | cookie_eai_sess: ZJU_COOKIE 21 | dingtalk_token: DINGTALK_TOKEN 22 | steps: 23 | - name: 打卡 24 | uses: upupming/zhr-action@release 25 | with: 26 | username: ${{ secrets[matrix.username] }} 27 | password: ${{ secrets[matrix.password] }} 28 | cookie_eai_sess: ${{ secrets[matrix.cookie_eai_sess] }} 29 | dingtalk_token: ${{ secrets[matrix.dingtalk_token] }} 30 | env: 31 | ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # zhr-action-demo 2 | 3 |

4 | 5 |

6 | 7 | > GitHub Action Demo for https://github.com/upupming/zhr-action 8 | 9 | 浙江大学健康打卡自动打卡脚本 GitHub Action 例子,只需一步 Fork 即可使用,每天定时帮你自动打卡。 10 | 11 | - 🔔 2022.12.25 学校已经不再要求打卡,参考 [zhr-action/#7](https://github.com/upupming/zhr-action/issues/7),可以自行停用此脚本。 12 | 13 | ```txt 14 | 【关于进一步优化校园疫情防控举措的通知】 15 | 16 | 1.本校师生员工不再要求每日打卡,可通过人脸识别、校园卡、身份证等多种方式入校,蓝码逐步停止使用,学校加快开发电子校园卡作为师生移动端身份凭证,过渡期认可凭蓝码进入。师生驾驶已备案机动车(凭通行证)可直接进入校园,如驾驶非备案机动车经身份查验后进入校园。离退休同志参照上述方式进入校园。 17 | ``` 18 | 19 | ## 使用方法 20 | 21 | 1. 直接 Fork 本仓库 22 | 23 | 2. 配置帐号(必须) 24 | 25 | Settings > Actions > General > Workflow permissions,改为 Read and write permissions,这样 Monthly Update Action 才能拥有更新仓库的权限,Monthly Update Action 每月运行一次,会向仓库添加一个新的 commit,是用来防止因为仓库长时间不活跃,而被 GitHub 自动禁用 Actions。 26 | 27 | Settings > Secrets > Actions > New repository secret, 添加 `ZJU_USERNAME`,内容为浙大通行证账号(学号),添加`ZJU_PASSWORD`,内容为浙大通行证密码。 28 | 29 | ![zju_account](https://user-images.githubusercontent.com/24741764/161693671-3659a9d5-aafa-4140-a277-1aa3e6373e48.png) 30 | 31 | 如果遇到[登录异常问题](https://github.com/upupming/zhr-action-demo/issues/10),可添加 `ZJU_COOKIE` 这个 secret,请参考 https://github.com/upupming/zhr-action#%E7%99%BB%E5%BD%95%E5%BC%82%E5%B8%B8 进行配置,`ZJU_PASSWORD` 和 `ZJU_COOKIE` 二选一即可。 32 | 33 | 3. 配置定时运行时间(可选) 34 | 35 | 在 .github/workflows/health-report.yml 中更改时间: 36 | 37 | ```yml 38 | on: 39 | workflow_dispatch: 40 | schedule: 41 | # `0 23 * * *` 表示UTC 23:00,即北京时间7:00打卡(经测试,实际运行时间比设定时间晚几分钟到几十分钟)。 42 | # 可以参考 https://crontab.guru/ 进行配置 43 | - cron: '0 23 * * *' 44 | ``` 45 | 46 | 4. 配置钉钉消息通知(可选) 47 | 48 | - 手机版钉钉 > 右上角添加 > 面对面建群 > 创建之后得到只有你一个人的群聊 49 | - 电脑版钉钉 > 群设置 > 智能群助手 > 添加机器人 > 自定义,名字随便填,安全设置选择`自定义关键字`,填`ZHR`,然后下一步复制Webhook。 50 | - Settings > Secrets > Actions > New repository secret, 添加`DINGTALK_TOKEN`,内容为刚才复制的Webhook中 `access_token=` 后面的内容。 51 | 52 | 5. 配置多人打卡(可选) 53 | 54 | 在 .github/workflows/health-report.yml 中添加一组,自行添加对应的Secrets。 55 | 56 | ```yml 57 | - username: ZJU_USERNAME 58 | password: ZJU_PASSWORD 59 | dingtalk_token: DINGTALK_TOKEN 60 | - username: ZJU_USERNAME2 61 | password: ZJU_PASSWORD2 62 | dingtalk_token: DINGTALK_TOKEN2 63 | ``` 64 | 65 | 6. 启用 Action(必须) 66 | 67 | Actions > I understand my workflows, go ahead and enable them 68 | 69 | Actions > zhr-action Demo > Enable workflow > Run workflow。 70 | 71 | Actions > Monthly Update Action > Enable workflow > Run workflow。 72 | 73 | 7. 停用 Action 74 | 75 | Actions > zhr-action Demo > Disable workflow。 76 | 77 | Actions > Monthly Update Action > Disable workflow。 78 | --------------------------------------------------------------------------------