diff --git a/README.md b/README.md index cf18382..ef36350 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) diff --git a/action.yml b/action.yml index 1c2fbb9..26a4cdb 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/entrypoint.sh b/entrypoint.sh index ac014da..5ce55ce 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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\"" @@ -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" \ No newline at end of file