-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to schedule a workflow to run on specific branches #108
Comments
Hi @WilliamJamieson, yes, scheduling it to run on different branches is useful, and you should be able to do this already. SunPy currently does this for the Another benefit of maintaining a workflow file in each branch is that it keeps the status report easier to read. It may get difficult to quickly check the branch's test status if the jobs for all your branches are mixed into the same workflow run summary. This can get particularly complex if you have a chain of dependent jobs which must run in sequence (basic test -> complex tests -> doc tests). Some important things to do to get it working:
Do you think that approach would work for you? |
Thanks @ConorMacBride, I think this should work nicely for me. I did not realize this approach was possible. It might be a good idea to document an example of how to do this as part of these actions. I do have some questions about the requirements for the PAT (I am basically looking to create as limited a token in scope as possible), as I haven't really had a need to use them before:
|
Yeah, it would be good to properly document this. I think the fine grained token would be best because you can limit it to a single repository. I've not tried it but "actions: read and write" should be the minimum for the fine grained token. I can't remember the minimal settings for the old PAT. https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event |
Unfortunately, fine-grained tokens cannot be created with no expiration date, or at the very least one in the distant future (seems like the limit was 1year). This runs a bit contrary to the set-it and forget-it testing I want to schedule with the cron job (namely, release branches will see less and less activity as they age). For now I'll go with a classic token (unfortunately), or at least until github comes up with something for fine grained tokens that requires me to not think about them too much. For classic tokens it looks like it needs a |
@zanecodes, made a suggestion to me that may avoid the use of the PAT. Namely, turning the name: Scheduled builds
on:
# Allow manual runs through the web UI
workflow_dispatch:
schedule:
# ┌───────── minute (0 - 59)
# │ ┌───────── hour (0 - 23)
# │ │ ┌───────── day of the month (1 - 31)
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT)
- cron: '0 7 * * *' # Every day at 07:00 UTC
jobs:
sunpy_main:
uses: sunpy/sunpy/.github/workflows/ci.yml@main
sunpy_4_0:
uses: sunpy/sunpy/.github/workflows/[email protected]
sunpy_4_1:
uses: sunpy/sunpy/.github/workflows/[email protected] I think the issue then becomes that There are a few downsides to this, most notably being that this action won't affect any badges indicating the CI status on a given branch. So it is probably not that useful to me. The method you proposed earlier doesn't suffer from this issue. |
Yeah, it would be good if the tokens would last for longer. Maybe there is some way to add a job to I hadn't realised that the reusable workflows could now be nested. This used to not be possible but I see it now is! (https://docs.github.com/en/actions/using-workflows/reusing-workflows#nesting-reusable-workflows) Making sure it builds the correct branch is important and passing the |
I think I will also use the same method in ASDF as well. Let me know if you figure out how to automatically notify when a token expires. |
Apparently GitHub should email the creator of the token when its about to expire: https://github.blog/changelog/2021-07-26-expiration-options-for-personal-access-tokens/#:~:text=When%20using%20a%20personal%20access,as%20the%20expiration%20date%20approaches. |
Ah, you're right. I now remember that the email got buried amongst 100s of other emails in the organisation email account |
It would be nicer if it just raised an issue. |
#142 added support for passing a specific branch to run a workflow, although I think this issue still raises a useful point, so I've made the title more specific. |
I would like to be able to pass a specific branch to an OpenAstronomy workflow, so that I can use them to run a cron job against my release branches. Normally, to schedule a cron job on the non default branch one needs to specify:
in the checkout phase.
Ideally, I would like to able to say, specify say
cron-branches:
to thetox
workflow. When the workflow is triggered by a thecron
it launch the workflow on each of thecron-branches
rather than on the default branch for the workflow. That is ifThis workflow would launch 6 actions, one action for each env on each of the branches. Then if not triggered by
cron
it would just run on the normal default branch.Doing this would let me schedule my CI to run on my
main
andrelease
branches so the CI gets run even if no PRs get opened or merged in a given time period.The text was updated successfully, but these errors were encountered: