Reputation: 1836
I am trying to configure a github workflow, I have managed to configure it on push event. However what if I need it to run on after a time period has passed?
What I have understood from the documentation is that it can be achieved using a schedule.
name: Release Management
on:
schedule:
- cron: "*/5 * * * *"
How do I specify the branch that the action will run on ?
My end goal is to automate releases.
Upvotes: 57
Views: 33917
Reputation: 41880
If you take a look at the documentation here you will see that the GITHUB_SHA
associated with the on: schedule
event is "Last commit on default branch." This is what will be checked out by default when you use the actions/checkout
action.
If your repository's default branch is master
(which in general is the case) this workflow will checkout the last commit on master
when it triggers.
name: Release Management
on:
schedule:
- cron: "*/5 * * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
If you want to checkout a different branch you can specify with parameters on the checkout action. This workflow will checkout the last commit on the some-branch
branch.
name: Release Management
on:
schedule:
- cron: "*/5 * * * *"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: some-branch
See documentation for the actions/checkout
action for other options.
Upvotes: 103