-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @GrantBirki! Left a few comments.
Co-authored-by: Cina Saffary <[email protected]>
Co-authored-by: Cina Saffary <[email protected]>
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/exec
package is utilized to save thestdout
andstderr
streams 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 ofstdout
command-stderr
: contains the string results ofstderr
But wait, there is more! ⭐
Since we are saving the
stdout
to 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-url
output 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
dev
environments started breaking. This was a direct result of #210This is because we are trying to save the
stdout
of 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
dev
environment 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-url
output that gets saved as well.Example 📸
resolves: #211
Thanks! ⭐