diff --git a/README.md b/README.md index 5395464..b84330c 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,7 @@ jobs: | --- | --- | --- | --- | | `args` | Arguments passed to `serverless` | `true` | | `aws-credentials` | Whether to use credentials stored in the local environment (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) | `false` | | -| `entrypoint` | Serverless entrypoint. For example: `/bin/sh` | `false` | `/entrypoint.sh` | -| `install-packages` | Comma-separated list of packages to install prior to running `serverless {args}` | `false` | | +| `install-packages` | Space-separated list of packages to install prior to running `serverless {args}` | `false` | | | `serverless-version` | Version of the Serverless Framework to use | `false` | `latest` | | `working-directory` | Folder where your configuration is located | `false` | `.` | @@ -62,7 +61,7 @@ jobs: ### Minimal example ```yaml - name: Deploy - uses: serverless/github-action@v3.2 + uses: serverless/github-action@v4.0 with: args: deploy ``` @@ -70,7 +69,7 @@ jobs: ### Use local credentials ```yaml - name: Deploy with local credentials - uses: serverless/github-action@v3.2 + uses: serverless/github-action@v4.0 with: aws-credentials: true # or yes args: deploy @@ -79,28 +78,19 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} ``` -### Use a different entrypoint -```yaml - - name: Deploy with a different entrypoint - uses: serverless/github-action@v3.2 - with: - entrypoint: /bin/sh - args: -c "serverless deploy" -``` - ### Install packages and deploy ```yaml - name: Install packages and deploy - uses: serverless/github-action@v3.2 + uses: serverless/github-action@v4.0 with: - install-packages: serverless-offline,serverless-prune-plugin + install-packages: serverless-offline serverless-prune-plugin args: deploy ``` ### Use a particular Serverless Framework CLI version ```yaml - name: Deploy using a particular version of serverless - uses: serverless/github-action@v3.2 + uses: serverless/github-action@v4.0 with: serverless-version: 2 args: deploy @@ -109,42 +99,17 @@ jobs: ### Change your working directory ```yaml - name: Deploy from a particular working directory - uses: serverless/github-action@v3.2 + uses: serverless/github-action@v4.0 with: working-directory: ./foo args: deploy ``` -## Usage with serverless plugins -Change your action in this way, according to [this issue](https://github.com/serverless/github-action/issues/28), thanks to @matthewpoer: -```yaml - - name: Install Plugin and Deploy - uses: serverless/github-action@v3.2 - with: - args: -c "serverless plugin install --name && serverless deploy" - entrypoint: /bin/sh -``` - -## Fix "This command can only be run in a Serverless service directory" error -Change your action in this way, according to [this issue](https://github.com/serverless/github-action/issues/53#issuecomment-1059839383), thanks to @nikhuber: -```yaml - - name: Enter dir and deploy - uses: serverless/github-action@v3.2 - with: - args: -c "cd ./ && serverless deploy" - entrypoint: /bin/sh -``` - - -## Use serverless v1 or v2 -Change the action with one of the following: +## Use a previous version +Change the action with `@{version}`, for example: ```yaml -uses: serverless/github-action@v1 +uses: serverless/github-action@v3.2 ``` -```yaml -uses: serverless/github-action@v2 -``` - ## License diff --git a/action.yml b/action.yml index dcb38ff..c166ecc 100644 --- a/action.yml +++ b/action.yml @@ -7,13 +7,14 @@ branding: inputs: args: description: 'Arguments passed to `serverless`' - required: true + required: false + default: none aws-credentials: description: 'Whether to use credentials stored in the local environment (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)' required: false default: 'false' install-packages: - description: 'Comma-separated list of packages to install prior to running `serverless {args}`' + description: 'Space-separated list of packages to install prior to running `serverless {args}`' required: false default: none serverless-version: diff --git a/entrypoint.sh b/entrypoint.sh index e4eafd8..d799dfd 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,14 +1,19 @@ #!/bin/sh -l +if [ "$5" == "none" ]; then + echo "You need to specify at least one argument, like `deploy`" + exit 1 +fi + cd $1 + npm i -g serverless@$2 -PACKAGES_TO_INSTALL=$3 -if [ $3 != "none" ]; then - npm i -g ${PACKAGES_TO_INSTALL//,/\ } +if [ "$3" != "none" ]; then + npm i -g $3 fi WITH_LOCAL_CREDENTIALS="" -if [ $4 = "true" ] || [ $4 = "yes" ]; then +if [ "$4" = "true" ] || [ "$4" = "yes" ]; then WITH_LOCAL_CREDENTIALS="--use-local-credentials" fi