-
I would like to trigger my github actions workflow to run once a week,only if there have been any pushes made to the repo in that week. Is there any way to do this? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you want your workflow run weekly, you need to set Scheduled events for the workflow. A simple demo:
You can see I set the key of the cache contains the commit SHA of current workflow run, when execute the cache action , it will check whether the specified key matchs an existing cache. If the key matchs an existing cache ( cache-hit is true ), it will restore this cache to the specified path on the local, and overwrite the file created in the " Create cache file" step in the path. If the key doesn’t match any existing cache ( cache-hit is false ), the action will save the file in the " Create cache file" step in the specified path as a cache with the specified key. In each subsequent step, use the if conditional to skip the subsequent step when the cache-hit is true. |
Beta Was this translation helpful? Give feedback.
-
I made an action for that austenstone/schedule |
Beta Was this translation helpful? Give feedback.
@benstear ,
If you want your workflow run weekly, you need to set Scheduled events for the workflow.
If you want the workflow runs only when have pushes in that week, you need to compare whether the commit SHA ( github.sha ) of current workflow run is different with that of the last workflow run.
You can use cache action to store and pass the commit SHA in each workflow run.
A simple demo: