action-hosting-deploy
action-hosting-deploy copied to clipboard
Impl: Remove preview channel on pr close
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
Hold on, let me fix the deploy preview yml
Edit: done, ready for review
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 😄
I totally missed that. I will look into it, looks like it'll work though. Thanks @napei
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.
Great job! Can't wait for this to be released 😎
I'll be spending time on this tomorrow.
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
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.mergedand/or
- name: pull request if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == trueI 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
@jhuleatt thoughts?
Curious how progress on this is going. Would love to see this feature land!
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.
Bumping this was one of the first things I went looking for after I setup CI/CD. Great initiative taking this on!
@kozr Any updates? I really need this on my project :sweat_smile:
Any update?
Why this is not merged yet?
Nothing about this?
it has been 3 years... I dont understand this is a really nice feature!
Better to rewrite it than to fix conflicts with 3 years worth of changes.