Skip to content

Commit 9cc40dc

Browse files
authored
feat: Add Netlify output as action outputs
* Add command output * add to contrib and readme * fix name in action
1 parent 20cf18b commit 9cc40dc

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ The inputs this action uses are:
4343
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |
4444
| `node_version` | `false` | '' | (Optional) Node version or other arguments passed to [nvm install](https://github.com/nvm-sh/nvm#usage) |
4545

46+
47+
### Outputs
48+
49+
The outputs for this action are:
50+
51+
`NETLIFY_OUTPUT`
52+
53+
Full output of the action
54+
55+
`NETLIFY_PREVIEW_URL`
56+
57+
The url of deployment preview.
58+
59+
`NETLIFY_LOGS_URL`
60+
61+
The url of the logs.
62+
63+
`NETLIFY_LIVE_URL`
64+
65+
The url of the live deployed site.
66+
67+
4668
## Example
4769

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

149171
- [tpluscode](https://github.com/tpluscode)
172+
- [wallies](https://github.com/wallies)

action.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ inputs:
5353
required: false
5454
default: ''
5555

56+
outputs:
57+
NETLIFY_OUTPUT:
58+
description: "netlify command output"
59+
NETLIFY_PREVIEW_URL:
60+
description: "deployment preview URL"
61+
NETLIFY_LOGS_URL:
62+
description: "deployment preview logs url"
63+
NETLIFY_LIVE_URL:
64+
description: "deployment URL"
65+
5666
runs:
5767
using: 'docker'
5868
image: 'Dockerfile'

entrypoint.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ fi
3636
eval ${BUILD_COMMAND:-"npm run build"}
3737

3838
# Export token to use with netlify's cli
39-
export NETLIFY_SITE_ID=$NETLIFY_SITE_ID
40-
export NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN
39+
export NETLIFY_SITE_ID="$NETLIFY_SITE_ID"
40+
export NETLIFY_AUTH_TOKEN="$NETLIFY_AUTH_TOKEN"
4141

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

@@ -50,4 +50,14 @@ then
5050
fi
5151

5252
# Deploy with netlify
53-
eval $COMMAND
53+
OUTPUT=$(sh -c "$COMMAND")
54+
55+
NETLIFY_OUTPUT=$(echo "$OUTPUT")
56+
NETLIFY_PREVIEW_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') #Unique key: --
57+
NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') #Unique key: app.netlify.com
58+
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
59+
60+
echo "::set-output name=NETLIFY_OUTPUT::$NETLIFY_OUTPUT"
61+
echo "::set-output name=NETLIFY_PREVIEW_URL::$NETLIFY_PREVIEW_URL"
62+
echo "::set-output name=NETLIFY_LOGS_URL::$NETLIFY_LOGS_URL"
63+
echo "::set-output name=NETLIFY_LIVE_URL::$NETLIFY_LIVE_URL"

0 commit comments

Comments
 (0)