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 an optional base directory #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ your workflow file.

The inputs this action uses are:

| Name | Required | Default | Description |
|:----:|:--------:|:-------:|:-----------:|
| `NETLIFY_AUTH_TOKEN` | `true` | N/A | The token needed to deploy your site ([generate here](https://app.netlify.com/user/applications#personal-access-tokens))|
| `NETLIFY_SITE_ID` | `true` | N/A | The site to where deploy your site (get it from the API ID on your Site Settings) |
| `NETLIFY_DEPLOY_MESSAGE` | `false` | '' | An optional deploy message |
| `build_directory` | `false` | `'build'` | The directory where your files are built |
| `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 |
| Name | Required | Default | Description |
| :----------------------: | :------: | :-------------: | :----------------------------------------------------------------------------------------------------------------------: |
| `NETLIFY_AUTH_TOKEN` | `true` | N/A | The token needed to deploy your site ([generate here](https://app.netlify.com/user/applications#personal-access-tokens)) |
| `NETLIFY_SITE_ID` | `true` | N/A | The site to where deploy your site (get it from the API ID on your Site Settings) |
| `NETLIFY_DEPLOY_MESSAGE` | `false` | '' | An optional deploy message |
| `build_directory` | `false` | `'build'` | The directory where your files are built |
| `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 |
| `base_directory` | `false` | '' | The directory where the commands will be executed |

## Example

Expand All @@ -65,7 +66,7 @@ jobs:
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}"
NETLIFY_DEPLOY_MESSAGE: 'Prod deploy v${{ github.ref }}'
NETLIFY_DEPLOY_TO_PROD: true
```

Expand All @@ -89,5 +90,4 @@ jobs:
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

```
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ inputs:
required: false
default: 'npm run build'

base_directory:
description: 'The directory where the commands will be executed'
required: false
default: ''

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

branding:
icon: activity
Expand Down
13 changes: 13 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ BUILD_DIRECTORY=$4
FUNCTIONS_DIRECTORY=$5
INSTALL_COMMAND=$6
BUILD_COMMAND=$7
BASE_DIRECTORY=$8

# Navigate to the base directory if one has been specified
if [[ $BASE_DIRECTORY ]]
then
cd $BASE_DIRECTORY
fi

# Install dependencies
eval ${INSTALL_COMMAND:-"npm i"}
Expand All @@ -27,3 +34,9 @@ then
else
netlify deploy --dir=$BUILD_DIRECTORY --functions=$FUNCTIONS_DIRECTORY --message="$INPUT_NETLIFY_DEPLOY_MESSAGE"
fi

# Navigate back to the original directory if a base directory has been specified
if [[ $BASE_DIRECTORY ]]
then
cd -
fi