This workflow allows to schedule execution of serverless lambda functions. Some services like Vercel make deployment of lambdas very easy, but do not give you an option to execute them on schedule. I needed it in my own app (link below) to regularly cleanup a database of items that users save.
The trick is the cron jobs. For example, by adding this to your action:
on: schedule: - cron: "0 */1 * * *"
you can schedule your workflow to be run every 1 hour.
The cool thing is that you can manage authentication and all kinds of environment variables INSIDE your lambda and turn in into a simple API for the workflow to call: no credentials and arguments needed.
curl is accessible out-of-the-box so you can just run the command using the
run field of the job.
- Maintainer Must-Haves
This is a relatively simple workflow so I'm going to just share YAML code here:
name: lambda-scheduler on: schedule: - cron: "0 */1 * * *" jobs: request: name: Request runs-on: ubuntu-latest steps: - name: Cleanup run: curl https://yourcoolwebsite.com/api/cleanup
The workflow is used in this repository. This is a Pocket-like app that allows you to save links for further reading without keeping them as open tabs. Any link older than 24 hours is automatically removed.