diff --git a/README.md b/README.md index 831bff2..de56c82 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 ``` @@ -89,5 +90,4 @@ jobs: with: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - ``` diff --git a/action.yml b/action.yml index 6a9d810..739f7cf 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -54,6 +59,7 @@ runs: - ${{ inputs.functions_directory }} - ${{ inputs.install_command }} - ${{ inputs.build_command }} + - ${{ inputs.base_directory }} branding: icon: activity diff --git a/entrypoint.sh b/entrypoint.sh index 918f3fe..5b258a3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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"} @@ -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