nodejs.dev icon indicating copy to clipboard operation
nodejs.dev copied to clipboard

convert comment based action to be label based

Open MylesBorins opened this issue 3 years ago • 12 comments

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.

MylesBorins avatar Aug 11 '20 23:08 MylesBorins

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).

mmarchini avatar Aug 11 '20 23:08 mmarchini

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

nschonni avatar Aug 11 '20 23:08 nschonni

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

MylesBorins avatar Aug 11 '20 23:08 MylesBorins

If we switch to labels does that mean only members can start the ci and create a preview link?

benhalverson avatar Aug 11 '20 23:08 benhalverson

Yes

mmarchini avatar Aug 11 '20 23:08 mmarchini

but folks with a triage role could kick it off as well

MylesBorins avatar Aug 12 '20 01:08 MylesBorins

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.

JasonEtco avatar Aug 12 '20 05:08 JasonEtco

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)

mmarchini avatar Aug 12 '20 05:08 mmarchini

Took a try with https://github.com/nodejs/nodejs.dev/pull/851

nschonni avatar Aug 13 '20 01:08 nschonni

Potentially, the label could be added to PULL_REQUEST_TEMPLATE frontmatter if a preview is wanted on all PRs

nschonni avatar Aug 13 '20 01:08 nschonni

There is create preview that works now.

marcustisater avatar Oct 11 '20 20:10 marcustisater

The label system is active, but the old workflow hasn't been retired

nschonni avatar Oct 11 '20 20:10 nschonni

The old workflow seems to have been removed. So closing this issue.

ovflowd avatar Aug 22 '22 00:08 ovflowd