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

feat: alias argument #11

Merged
merged 1 commit into from Jan 28, 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
27 changes: 27 additions & 0 deletions README.md
Expand Up @@ -40,6 +40,7 @@ The inputs this action uses are:
| `functions_directory` | `false` | N/A | The (optional) directory where your Netlify functions are stored |
| `install_command` | `false` | `npm i` | The (optional) command to install dependencies |
| `build_command` | `false` | `npm run build` | The (optional) command to build static website |
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |

## Example

Expand Down Expand Up @@ -91,3 +92,29 @@ jobs:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

```

### Use branch name to deploy

Will deploy under `https://${branchName}.${siteName}.netlify.app`

```yml
name: 'Netlify Deploy'

on:
push:
branches:
- '*'

jobs:
deploy:
name: 'Deploy'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: jsmrcaga/action-netlify-deploy@master
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
deploy_alias: ${{ GITHUB_REF##*/ }}
```
6 changes: 6 additions & 0 deletions action.yml
Expand Up @@ -42,6 +42,11 @@ inputs:
description: 'Command to build static website'
required: false
default: 'npm run build'

deploy_alias:
description: 'Deployment Subdomain name'
required: false
default: ''

runs:
using: 'docker'
Expand All @@ -54,6 +59,7 @@ runs:
- ${{ inputs.functions_directory }}
- ${{ inputs.install_command }}
- ${{ inputs.build_command }}
- ${{ inputs.deploy_alias }}

branding:
icon: activity
Expand Down
16 changes: 12 additions & 4 deletions entrypoint.sh
Expand Up @@ -9,6 +9,7 @@ BUILD_DIRECTORY=$4
FUNCTIONS_DIRECTORY=$5
INSTALL_COMMAND=$6
BUILD_COMMAND=$7
DEPLOY_ALIAS=$8

# Install dependencies
eval ${INSTALL_COMMAND:-"npm i"}
Expand All @@ -20,10 +21,17 @@ eval ${BUILD_COMMAND:-"npm run build"}
export NETLIFY_SITE_ID=$NETLIFY_SITE_ID
export NETLIFY_AUTH_TOKEN=$NETLIFY_AUTH_TOKEN

# Deploy with netlify
COMMAND="netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message=\"$INPUT_NETLIFY_DEPLOY_MESSAGE\""

if [[ $NETLIFY_DEPLOY_TO_PROD == "true" ]]
then
netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --prod --message="$INPUT_NETLIFY_DEPLOY_MESSAGE"
else
netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message="$INPUT_NETLIFY_DEPLOY_MESSAGE"
COMMAND+=" --prod"
fi

if [[ -n $DEPLOY_ALIAS ]]
then
COMMAND+=" --alias $COMMAND"
fi

# Deploy with netlify
eval $COMMAND