diff --git a/README.md b/README.md index 33cc0d4..aef40e5 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,19 @@ jobs: environment: 'production' ``` +Optionally, you can also pass a `workingDirectory` key to the action. This will allow you to specify a subdirectory of the repo to run the Wrangler command from. + +```yaml +jobs: + deploy: + # ... previous configuration ... + steps: + uses: cloudflare/wrangler-action@1.0.0 + with: + # ... api key and email ... + workingDirectory: 'subfoldername' +``` + ## Use cases ### Deploying when commits are merged to master diff --git a/action.yml b/action.yml index 54606be..818bc27 100644 --- a/action.yml +++ b/action.yml @@ -15,3 +15,5 @@ inputs: required: true environment: description: "The environment you'd like to publish your Workers project to - must be defined in wrangler.toml" + workingDirectory: + description: "The relative path which Wrangler commands should be run from" diff --git a/entrypoint.sh b/entrypoint.sh index 201f160..43740fb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -30,6 +30,11 @@ export CF_API_KEY="$INPUT_APIKEY" npm i @cloudflare/wrangler -g +if ! [ -z "$INPUT_WORKINGDIRECTORY" ] +then + cd $INPUT_WORKINGDIRECTORY +fi + if [ -z "$INPUT_ENVIRONMENT" ] then wrangler publish @@ -37,3 +42,7 @@ else wrangler publish -e "$INPUT_ENVIRONMENT" fi +if ! [ -z "$INPUT_WORKINGDIRECTORY" ] +then + cd $HOME +fi