Skip to content

Commit 87af643

Browse files
tpluscodejsmrcaga
authored andcommitted
feat: alias
* add alias parameter * add alias to netlify command * docs: mention new arg in readme * Update README.md * Update README.md
1 parent e654201 commit 87af643

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The inputs this action uses are:
4040
| `functions_directory` | `false` | N/A | The (optional) directory where your Netlify functions are stored |
4141
| `install_command` | `false` | `npm i` | The (optional) command to install dependencies |
4242
| `build_command` | `false` | `npm run build` | The (optional) command to build static website |
43+
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |
4344

4445
## Example
4546

@@ -91,3 +92,29 @@ jobs:
9192
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
9293
9394
```
95+
96+
### Use branch name to deploy
97+
98+
Will deploy under `https://${branchName}.${siteName}.netlify.app`
99+
100+
```yml
101+
name: 'Netlify Deploy'
102+
103+
on:
104+
push:
105+
branches:
106+
- '*'
107+
108+
jobs:
109+
deploy:
110+
name: 'Deploy'
111+
runs-on: ubuntu-latest
112+
113+
steps:
114+
- uses: actions/checkout@v1
115+
- uses: jsmrcaga/action-netlify-deploy@master
116+
with:
117+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
118+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
119+
deploy_alias: ${{ GITHUB_REF##*/ }}
120+
```

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ inputs:
4242
description: 'Command to build static website'
4343
required: false
4444
default: 'npm run build'
45+
46+
deploy_alias:
47+
description: 'Deployment Subdomain name'
48+
required: false
49+
default: ''
4550

4651
runs:
4752
using: 'docker'
@@ -54,6 +59,7 @@ runs:
5459
- ${{ inputs.functions_directory }}
5560
- ${{ inputs.install_command }}
5661
- ${{ inputs.build_command }}
62+
- ${{ inputs.deploy_alias }}
5763

5864
branding:
5965
icon: activity

entrypoint.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ BUILD_DIRECTORY=$4
99
FUNCTIONS_DIRECTORY=$5
1010
INSTALL_COMMAND=$6
1111
BUILD_COMMAND=$7
12+
DEPLOY_ALIAS=$8
1213

1314
# Install dependencies
1415
eval ${INSTALL_COMMAND:-"npm i"}
@@ -20,10 +21,17 @@ eval ${BUILD_COMMAND:-"npm run build"}
2021
export NETLIFY_SITE_ID=$NETLIFY_SITE_ID
2122
export NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN
2223

23-
# Deploy with netlify
24+
COMMAND="netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message=\"$INPUT_NETLIFY_DEPLOY_MESSAGE\""
25+
2426
if [[ $NETLIFY_DEPLOY_TO_PROD == "true" ]]
2527
then
26-
netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --prod --message="$INPUT_NETLIFY_DEPLOY_MESSAGE"
27-
else
28-
netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message="$INPUT_NETLIFY_DEPLOY_MESSAGE"
28+
COMMAND+=" --prod"
2929
fi
30+
31+
if [[ -n $DEPLOY_ALIAS ]]
32+
then
33+
COMMAND+=" --alias $COMMAND"
34+
fi
35+
36+
# Deploy with netlify
37+
eval $COMMAND

0 commit comments

Comments
 (0)