action-hosting-deploy icon indicating copy to clipboard operation
action-hosting-deploy copied to clipboard

Impl: Remove preview channel on pr close

Open kozr opened this issue 4 years ago • 14 comments

Description

Happy holidays!

Closes: #60

DEMO/EXAMPLE

The only difference between the demo branch in my fork and this branch is the .github/workflow/deploy-preview.yml. The main branch in my fork already has the preview template so I could test.

Although not completely done with what #60 was asking. I implemented the part where a preview channel would be closed after a PR closes (important to note that for a PR: closed != merged). There isn't an way to detect when a PR is merged unless we detect it from the branch in which it is merged into.

Edit: Found out that "closed" will trigger on PR merge. Hooray, it is what #60 is asking for.

Feedbacks are always welcome.

New things: removePreview Mostly identical to the structure of deployPreview except when parsing the results and the argument. An extra --force flag is added to skip cli prompts

  const removeDeployment = await execWithCredentials(
    ["hosting:channel:delete", channelId, "--force"],
    projectId,
    gacFilename
  );

I added a couple of tests that are similar to the ones for deployPreview

removeOnClose A new flag for the GitHub action to enable this feature, defaults to false. I documented the relevant information regarding the flag in README.md

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [x] Worked on my forked repo with a new Firebase project

Checklist:

  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] My changes generate no new warnings
  • [x] Any dependent changes have been merged and published in downstream modules

kozr avatar Dec 26 '20 05:12 kozr

Hold on, let me fix the deploy preview yml

Edit: done, ready for review

kozr avatar Dec 26 '20 05:12 kozr

There isn't an way to detect when a PR is merged unless we detect it from the branch in which it is merged into.

From that link I think you can infer that a PR has been "merged" regardless of if it's closed manually or merged?

github.event.pull_request.merged

and/or

- name: pull request
        if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true

I haven't tested anything, just making sure it's not missed 😄

napei avatar Dec 27 '20 22:12 napei

I totally missed that. I will look into it, looks like it'll work though. Thanks @napei

kozr avatar Dec 28 '20 00:12 kozr

I totally missed that. I will look into it, looks like it'll work though. Thanks @napei

Another extension for this behavior is for re-opening PRs if that's even detectable. That could be a separate issue alltogether and might already be implemented I'm just throwing ideas.

napei avatar Dec 28 '20 01:12 napei

Great job! Can't wait for this to be released 😎

maxprilutskiy avatar Dec 29 '20 20:12 maxprilutskiy

I'll be spending time on this tomorrow.

kozr avatar Dec 31 '20 08:12 kozr

Is it possible to post a comment back to the PR, once the preview channel is closed? This kind of feedback would be very helpful, dev would then know what's going on.

For instance, semantic-release pushes back to merged PRs comments like "hey, changes from this PR has just been included in release X.Y.Z", which is cool.

I think this would be pretty cool. I might try to make another PR for it later, this PR is getting kind of big to review.

Edit: I also think I'll need some time to think about this because reopening a PR won't post a new comment for the preview channel. So it might get confusing if a PR gets reopened

kozr avatar Dec 31 '20 22:12 kozr

There isn't an way to detect when a PR is merged unless we detect it from the branch in which it is merged into.

From that link I think you can infer that a PR has been "merged" regardless of if it's closed manually or merged?

github.event.pull_request.merged

and/or

- name: pull request
        if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true

I haven't tested anything, just making sure it's not missed 😄

Actually, I tested and realized that merged PR counts as "closed". That means the removal will get triggered on any PR merge anyway.

No changes needed I think... yay

https://github.com/kozr/action-hosting-deploy/pull/6 https://github.com/kozr/action-hosting-deploy/actions/runs/455240888

kozr avatar Dec 31 '20 22:12 kozr

@jhuleatt thoughts?

kozr avatar Jan 06 '21 01:01 kozr

Curious how progress on this is going. Would love to see this feature land!

0xdevalias avatar Feb 02 '21 00:02 0xdevalias

Curious how progress on this is going. Would love to see this feature land!

Likewise. Is this just waiting for review? We have a very high pull request velocity on our team and it's using up our channel quota.

kevmo314 avatar Apr 27 '21 17:04 kevmo314

Bumping this was one of the first things I went looking for after I setup CI/CD. Great initiative taking this on!

Guthers avatar Sep 03 '21 01:09 Guthers

@kozr Any updates? I really need this on my project :sweat_smile:

Seamoo13 avatar Nov 26 '21 10:11 Seamoo13

Any update?

rvargas avatar Mar 25 '22 21:03 rvargas

Why this is not merged yet?

radvansky-tomas avatar Dec 01 '22 01:12 radvansky-tomas

Nothing about this?

vinimarcili avatar Aug 08 '23 15:08 vinimarcili

it has been 3 years... I dont understand this is a really nice feature!

razine-bensari avatar Oct 12 '23 00:10 razine-bensari

Better to rewrite it than to fix conflicts with 3 years worth of changes.

kozr avatar Oct 27 '23 20:10 kozr