https://github.com/gr2m/set-cron-schedule-action
Set the cron schedule for a GitHub Action
https://github.com/gr2m/set-cron-schedule-action
Last synced: 4 months ago
JSON representation
Set the cron schedule for a GitHub Action
- Host: GitHub
- URL: https://github.com/gr2m/set-cron-schedule-action
- Owner: gr2m
- License: isc
- Created: 2021-06-06T22:37:16.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-23T19:43:47.000Z (almost 4 years ago)
- Last Synced: 2026-02-16T01:48:41.857Z (5 months ago)
- Language: JavaScript
- Homepage: https://github.com/marketplace/actions/set-cron-schedule
- Size: 196 KB
- Stars: 9
- Watchers: 1
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# set-cron-schedule-action
> Updates the current GitHub Action workflow's cron trigger based on a list of cron expressions
[](https://github.com/gr2m/set-cron-schedule-action/actions)
## Usage
[cron expressions](https://en.wikipedia.org/wiki/Cron#CRON_expression) are powerful, but if you want to run a task on a specific date and time you are out of luck with GitHub Actions. The best you can do is to set a specific date and time that will trigger yearly.
With this action, you can programmatically update the cron schedule for an action. So instead of running your action frequently and then checking if there is anything to do, you can schedule the action to run on a specific date, then update the schedule to run on another date.
Note that [`${{ secrets.GITHUB_TOKEN}}`](https://docs.github.com/en/actions/reference/authentication-in-a-workflow) cannot be used for authentication, as it lacks the permission to update files in `.github/workflows/`. You need to [create a personal access token with the `workflow` scope](https://github.com/settings/tokens/new?scopes=workflow) and save it in your repository's secrets as `PAT_WITH_WORKFLOW_SCOPE` in order to make the example below work.
```yml
name: Reminder
on:
schedule:
- cron: "0 10 * * 2"
jobs:
reminder:
runs-on: ubuntu-latest
steps:
- run: do-the-thing.sh
- uses: gr2m/set-cron-schedule-action@v2
with:
token: ${{ secrets.PAT_WITH_WORKFLOW_SCOPE }}
cron: |
0 10 * * 2
0 15 * * 4
# optional: set workflow id or file name
workflow: my-workflow.yml
# optional: Defaults to "ci($WORKFLOW_NAME): update cron schedule: $CRON_EXPRESSIONS".
# $WORKFLOW_NAME and $CRON_EXPRESSIONS will be replaced.
message: "update cron for next reminder to do the thing"
```
## License
[ISC](LICENSE)