command-output
command-output copied to clipboard
Add regex param to capture only a portion of stdout?
Thank you for creating this action, I'm using it right now in a workflow and it works great.
Perhaps a useful feature would be the ability to pass a regular expression that captures only a part of stdout
/ stderr
into a third variable. For example, see my code below where I'm using two steps to accomplish this (workflow file here). It's not that bad, but it seems like there should be a better way.
- name: Create preview channel
uses: mathiasvr/[email protected]
id: create_preview
with:
run: firebase hosting:channel:create ${{ github.event.pull_request.number }}
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
# Output should look like this:
#
# + hosting:channel: Channel <pr_number> has been created on site <project_id>.
# + hosting:channel: Channel <pr_number> will expire at <timestamp>.
# + hosting:channel: Channel URL: https://<project_id>--<pr_number>-<random_hash>.web.app
#
# To deploy to this channel, use firebase hosting:channel:deploy <pr_number>.
- name: Get preview channel URL from stdout
uses: mathiasvr/[email protected]
id: preview_url
with:
run: echo '${{ steps.create_preview.outputs.stdout }}' | perl -ne 'print "$1\n" if /(https:\/\/[^\s]+\.web\.app)/'
# Output: https://<project_id>--<pr_number>-<random_hash>.web.app