A Proof of Concept for scheduling a GitHub Action Workflow based on the output of the CarbonAwareSDK
Prerequisites: create personal access token named WORKFLOW_TOKEN that has workflow write access.
-
on a PR merge, the workflow runs
-
Sets correct permissions for bash script
-
copy/overwrite the scheduledWorkflow_template.yml into the workflows/ folder
-
call scheduleWorkflowUsingHostedCarbonAwareSDK.bash
- calls hosted version of CarbonAwareSDK
- extract first optimal time to run 10 min job within next 24 hours in 'ukwest' region (can change these parameters, only using these for the PoC).
- output reformatted timestamp into correct format for 'cron' trigger of workflow
-
take output and replace the templated schedule in the newly copied/overwritten scheduledWorkflow.yml workflow
-
Commit this updated workflow
-
scheduledWorkflow workflow is now scheduled to run at the time forecasted to have the lowest carbon intensity
-
scheduledWorkflow.yml ends by deleting itself to prevent it running every year
-
- You can still manually trigger using the the scheduledWorkflow workflow using 'workflow_dispatch:'
- Requires paid for subscriptions of either ElectricityMaps API or WattTime API before it can forecast emission data
- Instead of the hosted test version, it will have to clone the carbon-aware-sdk locally and then configure it with the credentials from account(s) above in the delayCalculator.yml workflow