Skip to content

Commit

Permalink
Add versioning and local credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlawson committed May 18, 2024
1 parent a1abb42 commit 9e4d135
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 10 deletions.
59 changes: 55 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,67 @@ jobs:
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
```

## Specify a particular version
## Configuration

| `with:` | Description | Required | Default |
| --- | --- | --- | --- |
| `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` | |
| `serverless-version` | Version of the Serverless Framework to use | `false` | `latest` |
| `working-directory` | Folder where your configuration is located | `false` | `.` |

## Examples

### Minimal example
```yaml
- name: Deploy
uses: serverless/[email protected]
with:
args: deploy
```
### Use local credentials
```yaml
- name: Deploy with local credentials
uses: serverless/[email protected]
with:
aws-credentials: true # or yes
args: deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
```
### Use a different entrypoint
```yaml
- name: Deploy with a different entrypoint
uses: serverless/[email protected]
with:
entrypoint: /bin/sh
args: -c "serverless deploy"
```
### Install packages and deploy
```yaml
- name: Install packages and deploy
uses: serverless/[email protected]
with:
install-packages: serverless-offline,serverless-prune-plugin
args: deploy
```
### Use a particular Serverless Framework CLI version
```yaml
- name: Deploy with a particular version
- name: Deploy using a particular version of serverless
uses: serverless/[email protected]
with:
serverless-version: 3
serverless-version: 2
args: deploy
```
## Change your working directory
### Change your working directory
```yaml
- name: Deploy from a particular working directory
uses: serverless/[email protected]
Expand Down
13 changes: 9 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@ branding:
inputs:
args:
description: 'Arguments passed to `serverless`'
required: true
aws-credentials:
description: 'Whether to use credentials stored in the local environment (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)'
required: false
default: help
entrypoint:
description: 'Serverless entrypoint. For example: `/bin/sh`'
default: 'false'
install-packages:
description: 'Comma-separated list of packages to install prior to running `serverless {args}`'
required: false
default: none
serverless-version:
description: 'Version of the Serverless Framework to use (default: latest)'
required: false
Expand All @@ -26,8 +30,9 @@ runs:
args:
- ${{ inputs.working-directory }}
- ${{ inputs.serverless-version }}
- ${{ inputs.install-packages }}
- ${{ inputs.aws-credentials }}
- ${{ inputs.args }}
entrypoint: ${{ inputs.entrypoint }}

outputs:
version:
Expand Down
15 changes: 13 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/sh -l
cd $1
npm i -g serverless@${2/v/}
serverless $3
npm i -g serverless@$2

PACKAGES_TO_INSTALL=$3
if [[ $3 != "none" ]]; then
npm i -g ${PACKAGES_TO_INSTALL//,/\ }
fi

WITH_LOCAL_CREDENTIALS=""
if [[ $4 == "true" ]] || [[ $4 == "yes" ]]; then
WITH_LOCAL_CREDENTIALS="--use-local-credentials"
fi

serverless $5 $WITH_LOCAL_CREDENTIALS

0 comments on commit 9e4d135

Please sign in to comment.