Skip to content
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

Add command output #26

Merged
merged 3 commits into from Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -43,6 +43,28 @@ The inputs this action uses are:
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |
| `node_version` | `false` | '' | (Optional) Node version or other arguments passed to [nvm install](https://github.com/nvm-sh/nvm#usage) |


### Outputs

The outputs for this action are:

`NETLIFY_OUTPUT`

Full output of the action

`NETLIFY_PREVIEW_URL`

The url of deployment preview.

`NETLIFY_LOGS_URL`

The url of the logs.

`NETLIFY_LIVE_URL`

The url of the live deployed site.


## Example

### Deploy to production on release
Expand Down Expand Up @@ -147,3 +169,4 @@ Alternatively, create an `.nvmrc` file with the desired version range in your re
## Contributors

- [tpluscode](https://github.com/tpluscode)
- [wallies](https://github.com/wallies)
10 changes: 10 additions & 0 deletions action.yml
Expand Up @@ -53,6 +53,16 @@ inputs:
required: false
default: ''

outputs:
NETLIFY_OUTPUT:
description: "netlify command output"
NETLIFY_PREVIEW_URL:
description: "deployment preview URL"
NETLIFY_LOGS_URL:
description: "deployment preview logs url"
NETLIFY_LIVE_URL:
description: "deployment URL"

runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
16 changes: 13 additions & 3 deletions entrypoint.sh
Expand Up @@ -36,8 +36,8 @@ fi
eval ${BUILD_COMMAND:-"npm run build"}

# Export token to use with netlify's cli
export NETLIFY_SITE_ID=$NETLIFY_SITE_ID
export NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN
export NETLIFY_SITE_ID="$NETLIFY_SITE_ID"
export NETLIFY_AUTH_TOKEN="$NETLIFY_AUTH_TOKEN"

COMMAND="$NETLIFY_CLI deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message=\"$INPUT_NETLIFY_DEPLOY_MESSAGE\""

Expand All @@ -50,4 +50,14 @@ then
fi

# Deploy with netlify
eval $COMMAND
OUTPUT=$(sh -c "$COMMAND")

NETLIFY_OUTPUT=$(echo "$OUTPUT")
NETLIFY_PREVIEW_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') #Unique key: --
NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') #Unique key: app.netlify.com
NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' | grep -Eov "netlify.com") #Unique key: don't containr -- and app.netlify.com

echo "::set-output name=NETLIFY_OUTPUT::$NETLIFY_OUTPUT"
echo "::set-output name=NETLIFY_PREVIEW_URL::$NETLIFY_PREVIEW_URL"
echo "::set-output name=NETLIFY_LOGS_URL::$NETLIFY_LOGS_URL"
echo "::set-output name=NETLIFY_LIVE_URL::$NETLIFY_LIVE_URL"