简体中文 / [English]


How to Properly Use GitHub Actions for Scheduled Tasks - A Detailed Guide

 

This article is currently an experimental machine translation and may contain errors. If anything is unclear, please refer to the original Chinese version. I am continuously working to improve the translation.

Note: This tutorial is not a general configuration guide for GitHub Actions. For how to configure GitHub Actions, please refer to the official GitHub documentation. This guide is relatively detailed, aiming to help everyone get started with my GitHub Actions-based projects within 10 minutes.

P.S. Although you can complete the setup on a mobile device, the mobile interface might differ from the desktop version. It’s recommended to use a computer to follow the steps below.

  1. To use GitHub Actions, you’ll first need a GitHub account. (Well, duh!) If you don’t have one, go ahead and sign up—it should be straightforward.

  2. Fork my repository: Go to the repository’s homepage and click the “Fork” button in the top-right corner. (And feel free to click the “Star” button nearby—much appreciated! :P)

    forkfork

  3. Enable GitHub Actions: After the forking process completes (give it a moment), click on the “Actions” tab, then click the green button labeled I understand my workflows... to enable GitHub Actions for your fork.

    actionsactions

  4. Set up Secrets: Navigate to Settings → Secrets → New Secret to add a secret. The required secrets vary from project to project. Make sure to set all the secrets as specified in the project’s README.

    secrets1secrets1

    secrets2secrets2

    After entering one secret, you can click “New Secret” again to add another. Take my first GitHub Actions project, Bilibili Daily Bonus, as an example. After setup, your Secrets page should look like this:

    secrets3-1secrets3-1

    secrets3-1secrets3-1

    Important: When entering secret names, make sure the case matches exactly as specified in the instructions!

    P.S. Normally, you shouldn’t enter sensitive information like usernames or passwords on third-party sites. However, secrets here are securely encrypted and managed by GitHub (now under Microsoft). Also, since the source code is open, the data processing logic is fully transparent. You don’t need to worry about your data’s security.

  5. Modify a file to trigger the scheduled task: Click the “Code” tab to return to the main page. Click the pencil icon on the right side of README.md to edit the file. Make any small change (e.g., add a space or comment), then commit the change.

    update1update1

    update2update2

    update3update3

  6. That’s it. Enjoy!

    If something goes wrong, GitHub will send an email to the address associated with your account. You can troubleshoot based on the error message. If you’re still stuck, feel free to open an issue or contact me directly via QQ. :)

Finally, a quick wrap-up: I’ve tried to make this guide as beginner-friendly as possible, especially for those who aren’t very familiar with GitHub or programming. The whole process really boils down to Fork → Enable Actions → Add Secrets → Commit a file to trigger the job. Thanks to GitHub Actions’ seamless integration and easy setup—and inspired by other similar projects—I realized I could “free-ride” GitHub Actions for running scheduled tasks. And because it’s so simple to configure, my hope is to make my little tools accessible even to non-programmers, which feels like a fun little experiment. Let me know what you think—go easy on me, please! :P

Written late at night, August 11th, 2020, 00:47

This article is licensed under the CC BY-NC-SA 4.0 license.

Author: lyc8503, Article link: https://blog.lyc8503.net/en/post/github-actions/
If this article was helpful or interesting to you, consider buy me a coffee¬_¬
Feel free to comment in English below o/