nodejs.dev
nodejs.dev copied to clipboard
convert comment based action to be label based
The amazing @mmarchini made an action for nodejs/node that using labels to kick off CI
https://github.com/nodejs/node/blob/master/.github/workflows/auto-start-ci.yml
I think we should convert the existing comment based trigger to trigger based on a label. I believe that the above yml and the existing staging action have everything needed to accomplish this... we should not have to update any credentials (although we should update docs).
One thing... this might not be able to be previewed in a PR... so there might be some fancy fork work needed, or alternatively land and prod to see if it works.
In theory changing the event to pull_request_target: [labeled]
, adding if: github.event.label.name == 'start-ci'
to the job and changing every use of github.event.issue.number
with github.event.number
should be enough for this use case, with the caveat that existing PRs need to be rebased for the action to trigger (because of https://github.com/nodejs/node/pull/34707#issuecomment-671516273). If that caveat doesn't work for this repo, the schedule
approach we use on core also works, but requires more changes (happy to help anyone who wants to work on it).
Makes sense to me. I think that if the preview is successful, it could also remove the label.
The instructions in https://github.com/nodejs/nodejs.dev/blame/695b54d12f249028b6120a2e7734fa6729e1e6b9/.github/PULL_REQUEST_TEMPLATE.md#L18 will also need to update if this is switched
The job I referenced on core removes the label as soon as it is kicked off. I think there is an additional label added if it fails I would imagine that pattern would be worth following
If we switch to labels does that mean only members can start the ci and create a preview link?
Yes
but folks with a triage role could kick it off as well
Could be worth updating the PR template with a checkbox like this, if only so that triagers/maintainers know without having to specifically be asked:
- [ ] This should be preview deployed
As a bonus, the action could also auto-add the label if that is checked - though it wouldn't trigger the next workflow (because Actions can't trigger Actions), but we could add it to the same pull_request.opened
workflow.
though it wouldn't trigger the next workflow (because Actions can't trigger Actions)
It works if you use a personal token (we can create one for @nodejs-github-bot and add it to the repo)
Took a try with https://github.com/nodejs/nodejs.dev/pull/851
Potentially, the label could be added to PULL_REQUEST_TEMPLATE frontmatter if a preview is wanted on all PRs
There is create preview
that works now.
The label system is active, but the old workflow hasn't been retired
The old workflow seems to have been removed. So closing this issue.