Save Wrangler Command Output to a Variable#213
Conversation
|
Hey @GrantBirki, thanks for the PR. Would your use case be satisfied if we implemented the |
|
@1000hz that would be even better! Do you mind if I alter this PR to make all the text that gets written to a file be written to the |
|
@GrantBirki that'd be wonderful. Thanks! |
|
@1000hz I have good news, this is ready for review! 🎉 I have tested that all code included in this pull request works: I managed to fully implement the Let me know if you have any questions. Thanks! |
1000hz
left a comment
There was a problem hiding this comment.
Nice work, @GrantBirki! Left a few comments.
Co-authored-by: Cina Saffary <itscina@gmail.com>
Co-authored-by: Cina Saffary <itscina@gmail.com>
|
Thanks for the contribution, @GrantBirki! |
|
Thank you! 🎉 |
Save Wrangler Command Output to a Variable
This pull request enables a more advanced usage of this Action in conjunction with other workflow steps. These changes allow users to gain the ability to parse the wrangler command's output in subsequent workflow steps should they need to.
The
@actions/execpackage is utilized to save thestdoutandstderrstreams to variables and then those variables are written to two new Actions outputs when this job completes. These two new outputs are as follows:command-output: contains the string results ofstdoutcommand-stderr: contains the string results ofstderrBut wait, there is more! ⭐
Since we are saving the
stdoutto a variable, it can now be parsed by this Action just a little bit more before exiting. I added in a bonus feature to this PR to detect if the command being run is a deployment for a Cloudflare Pages site or Worker. If it is a deployment, then thedeployment-urloutput gets populated.deployment-url: contains the string results of the URL that was deploy (ex:https://<your_pages_site>.pages.dev)Why?
I personally have several open source projects which I help maintain. We use this Action to deploy our Cloudflare Pages sites. Recently, our workflows for
devenvironments started breaking. This was a direct result of #210This is because we are trying to save the
stdoutof this Action by piping it to a file. This isn't really the best solution but it worked... at least for a while before it broke. This PR will prevent us from having to use choppy command line hacks in the future.Being able to capture the output of this command to get the unique
devenvironment URL for pages deployments is required by our workflows to use it in subsequent workflow steps. This pull request also solves that problem via the newdeployment-urloutput that gets saved as well.Example 📸
resolves: #211
Thanks! ⭐