├── .gitignore ├── .github └── workflows │ └── ci.yml ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | *bak 4 | .history 5 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | schedule: 8 | - cron: "0 0 * * *" 9 | 10 | jobs: 11 | autogreen: 12 | runs-on: ubuntu-latest 13 | 14 | permissions: 15 | contents: write 16 | 17 | steps: 18 | - name: Clone repository 19 | uses: actions/checkout@v3 20 | 21 | - name: Auto green 22 | run: | 23 | git config --local user.email "firjfijr576@gmail.com" 24 | git config --local user.name "firjfijr-m5-2" 25 | git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} 26 | git pull --rebase 27 | git commit --allow-empty -m "a commit a day keeps your girlfriend away" 28 | git push 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 everyone. 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # auto-green 2 | 3 | [![Build Status](https://github.com/justjavac/auto-green/workflows/ci/badge.svg?branch=master)](https://github.com/justjavac/auto-green/actions) 4 | 5 | 自动保持 GitHub 提交状态常绿。 6 | 7 | > a commit a day keeps your girlfriend away. 8 | 9 | ## 原理 10 | 11 | 使用 GitHub Actions 的定时任务功能,每隔一段时间自动执行 `git commit`,提交信息为 "a commit a day keeps your girlfriend away",灵感来自知乎问题[在 GitHub 上保持 365 天全绿是怎样一种体验?](https://www.zhihu.com/question/34043434/answer/57826281)下某匿名用户的回答: 12 | 13 | > 曾经保持了 200 多天全绿,但是冷落了女朋友,一直绿到现在。 14 | 15 | 有关 Github Action 的原理,可查看官方文档 [Github Action 简介](https://docs.github.com/cn/actions/learn-github-actions/introduction-to-github-actions) 16 | 17 | ## 使用 18 | 19 | - 点右上角 **Use this template** 按钮复制本 GitHub 仓库,**:warning: 千万不要 Fork,因为 fork 项目的动态并不会让你变绿 :warning:** 20 | - 修改 [ci.yml 文件的第 7、8 行](https://github.com/justjavac/auto-green/blob/master/.github/workflows/ci.yml#L7-L8) 去掉前面的 `#` 号 21 | - 修改 [ci.yml 文件的第 23、24 行](https://github.com/justjavac/auto-green/blob/master/.github/workflows/ci.yml#L19-L20) 为自己的 GitHub 账号和昵称 22 | - (可选) 你可以通过修改 [ci.yml 文件的第 8 行](https://github.com/justjavac/auto-green/blob/master/.github/workflows/ci.yml#L8)来调整频率 23 | 24 | 计划任务语法有 5 个字段,中间用空格分隔,每个字段代表一个时间单位。 25 | 26 | ```plain 27 | ┌───────────── 分钟 (0 - 59) 28 | │ ┌───────────── 小时 (0 - 23) 29 | │ │ ┌───────────── 日 (1 - 31) 30 | │ │ │ ┌───────────── 月 (1 - 12 或 JAN-DEC) 31 | │ │ │ │ ┌───────────── 星期 (0 - 6 或 SUN-SAT) 32 | │ │ │ │ │ 33 | │ │ │ │ │ 34 | │ │ │ │ │ 35 | * * * * * 36 | ``` 37 | 38 | 每个时间字段的含义: 39 | 40 | |符号 | 描述 | 举例 | 41 | | ----- | -----------| -------------------------------------------| 42 | | `*` | 任意值 | `* * * * *` 每天每小时每分钟 | 43 | | `,` | 值分隔符 | `1,3,4,7 * * * *` 每小时的 1 3 4 7 分钟 | 44 | | `-` | 范围 | `1-6 * * * *` 每小时的 1-6 分钟 | 45 | | `/` | 每 | `*/15 * * * *` 每隔 15 分钟 | 46 | 47 | **注**:由于 GitHub Actions 的限制,如果设置为 `* * * * *` 实际的执行频率为每 5 分执行一次。 48 | 49 | ## License 50 | 51 | [auto-green](https://github.com/justjavac/auto-green) is released under the MIT License. See the bundled [LICENSE](./LICENSE) file for details. 52 | --------------------------------------------------------------------------------