Generating a Personal Access Token (PAT)
In the upper right profile:
- Click on the profile picture
- Click on Settings (note that this is not the repository settings!)
- Click on < > Developer settings located at the bottom of the left hand side menu
- Click on Personal access tokens > Tokens (classic)
- Click on Generate new token > Generate new token (classic)
- Provide a description for the Note and check public_repo (without this checked, you will likely receive a 404 error when trying to access the Github API)
- Click Generate token at the bottom of the page
- Copy the PAT and store them in a specific environment and secret for future use
Storing and Using Secrets
In your repository of interest:
- Click on Settings (note that this is not the profile settings)
- Click on Environments on the left hand side menu
- Click New environment
- Add an appropriate environment name like API_Access
- Near the bottom, click Add secret
- Specify an environment variable name as ACCESS_TOKEN and paste your PAT from
- Access this environment in your workfow via environment: API_Access and reference the secret via ${{ secrets.ACCESS_TOKEN }}
Allow Manual Workflow Triggering
In the workflow, add:
This will allow you to manually trigger the workflow within the Actions tab of Github
Schedule Cron Job within Github Actions
In the workflow, add:
on:
# workflow_dispatch:
schedule:
- cron: '0 14 * * *' # 2pm UTC == 9am EST
# Triggering the Workflow Externally Via Github API
In the workflow, specify the event_type through the repository_dispatch custom event trigger:
on:
# workflow_dispatch:
# schedule:
# - cron: '0 14 * * *' # 2pm UTC == 9am EST
repository_dispatch:
types: [check_numba_python_comptability]
Then, this can be triggered through the Github API via cron-job.org:
- Login to cron-job.org
- Create a new cron job
- Choose an appropirate title
- Set the dispatch URL (e.g., https://api.github.com/repos/stumpy-dev/automate/dispatches)
- Select an execution schedule
- Click on the "Advanced" tab
- Add a Accept:application/vnd.github.v3+json key-value header
- Add a Authorization:token <Personal_Access_Token> key-value header
- Change the "Request Method" to "POST"
- And add a {"event_type": "check_numba_python_compatibility"} Request body