Skip to content

Commit 36f0d79

Browse files
committed
Add versioning and local credentials
1 parent a1abb42 commit 36f0d79

File tree

3 files changed

+77
-10
lines changed

3 files changed

+77
-10
lines changed

README.md

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,67 @@ jobs:
4646
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4747
```
4848

49-
## Specify a particular version
49+
## Configuration
50+
51+
| `with:` | Description | Required | Default |
52+
| --- | --- | --- | --- |
53+
| `args` | Arguments passed to `serverless` | `true` |
54+
| `aws-credentials` | Whether to use credentials stored in the local environment (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`) | `false` | |
55+
| `entrypoint` | Serverless entrypoint. For example: `/bin/sh` | `false` | `/entrypoint.sh` |
56+
| `install-packages` | Comma-separated list of packages to install prior to running `serverless {args}` | `false` | |
57+
| `serverless-version` | Version of the Serverless Framework to use | `false` | `latest` |
58+
| `working-directory` | Folder where your configuration is located | `false` | `.` |
59+
60+
## Examples
61+
62+
### Minimal example
63+
```yaml
64+
- name: Deploy
65+
uses: serverless/[email protected]
66+
with:
67+
args: deploy
68+
```
69+
70+
### Use local credentials
71+
```yaml
72+
- name: Deploy with local credentials
73+
uses: serverless/[email protected]
74+
with:
75+
aws-credentials: true # or yes
76+
args: deploy
77+
env:
78+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
79+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
80+
```
81+
82+
### Use a different entrypoint
83+
```yaml
84+
- name: Deploy with a different entrypoint
85+
uses: serverless/[email protected]
86+
with:
87+
entrypoint: /bin/sh
88+
args: -c "serverless deploy"
89+
```
90+
91+
### Install packages and deploy
92+
```yaml
93+
- name: Install packages and deploy
94+
uses: serverless/[email protected]
95+
with:
96+
install-packages: serverless-offline,serverless-prune-plugin
97+
args: deploy
98+
```
99+
100+
### Use a particular Serverless Framework CLI version
50101
```yaml
51-
- name: Deploy with a particular version
102+
- name: Deploy using a particular version of serverless
52103
uses: serverless/[email protected]
53104
with:
54-
serverless-version: 3
105+
serverless-version: 2
55106
args: deploy
56107
```
57108
58-
## Change your working directory
109+
### Change your working directory
59110
```yaml
60111
- name: Deploy from a particular working directory
61112
uses: serverless/[email protected]

action.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ branding:
77
inputs:
88
args:
99
description: 'Arguments passed to `serverless`'
10+
required: true
11+
aws-credentials:
12+
description: 'Whether to use credentials stored in the local environment (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)'
1013
required: false
11-
default: help
12-
entrypoint:
13-
description: 'Serverless entrypoint. For example: `/bin/sh`'
14+
default: 'false'
15+
install-packages:
16+
description: 'Comma-separated list of packages to install prior to running `serverless {args}`'
1417
required: false
18+
default: none
1519
serverless-version:
1620
description: 'Version of the Serverless Framework to use (default: latest)'
1721
required: false
@@ -26,8 +30,9 @@ runs:
2630
args:
2731
- ${{ inputs.working-directory }}
2832
- ${{ inputs.serverless-version }}
33+
- ${{ inputs.install-packages }}
34+
- ${{ inputs.aws-credentials }}
2935
- ${{ inputs.args }}
30-
entrypoint: ${{ inputs.entrypoint }}
3136

3237
outputs:
3338
version:

entrypoint.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#!/bin/sh -l
22
cd $1
3-
npm i -g serverless@${2/v/}
4-
serverless $3
3+
npm i -g serverless@$2
4+
5+
PACKAGES_TO_INSTALL=$3
6+
if [ $3 != "none" ]; then
7+
npm i -g ${PACKAGES_TO_INSTALL//,/\ }
8+
fi
9+
10+
WITH_LOCAL_CREDENTIALS=""
11+
if [ $4 == "true" ] || [ $4 == "yes" ]; then
12+
WITH_LOCAL_CREDENTIALS="--use-local-credentials"
13+
fi
14+
15+
serverless $5 $WITH_LOCAL_CREDENTIALS

0 commit comments

Comments
 (0)