Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
先说明我如何实现这个功能。
每一天打卡时,随机决定明天 8 am 到 2 pm 之间何时打卡,纪录时间到 timestamp.txt (这个文件在代码仓库里,因此更新文件需要 Commit & Push 到 Github 仓库)。
设定 workflow 从每天 8 点到下午 4 点,每隔一个小时检查一次当前时间是否超过 timestamp.txt 纪录的时间。如果尚未超过,workflow 直接结束;否则,打卡,更新 timestamp.txt。
因为 Github 不会完全按照你设定的时间执行 Action ,延迟一个小时以上是很常见的,所以 2pm 后我设定多打卡两次,以防万一。
之前看 issue#9 有人讨论过这个功能。一种方案 sleep 随机一段很长的时间(e.g 六七个小时)再打卡,但是对大部分依赖 Github Actions 每月免费额度的同学而言不太现实。
我的方案不一定是最好,但试了几天能用(主要是前几天被查水表,一怒之下把东西写了哈哈),消耗的每月免费额度也不多,估计每月 100 分钟。真想实现完全随机的同学建议找其他家服务器,或是直接在自己的电脑上设定定时任务。