Skip to content

Commit 32bfd50

Browse files
committed
Install package/plugin functionality
1 parent 033f524 commit 32bfd50

File tree

3 files changed

+22
-51
lines changed

3 files changed

+22
-51
lines changed

README.md

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ jobs:
5252
| --- | --- | --- | --- |
5353
| `args` | Arguments passed to `serverless` | `true` |
5454
| `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` | |
55+
| `install-packages` | Space-separated list of packages to install prior to running `serverless {args}` | `false` | |
5756
| `serverless-version` | Version of the Serverless Framework to use | `false` | `latest` |
5857
| `working-directory` | Folder where your configuration is located | `false` | `.` |
5958

@@ -62,15 +61,15 @@ jobs:
6261
### Minimal example
6362
```yaml
6463
- name: Deploy
65-
uses: serverless/github-action@v3.2
64+
uses: serverless/github-action@v4.0
6665
with:
6766
args: deploy
6867
```
6968
7069
### Use local credentials
7170
```yaml
7271
- name: Deploy with local credentials
73-
uses: serverless/github-action@v3.2
72+
uses: serverless/github-action@v4.0
7473
with:
7574
aws-credentials: true # or yes
7675
args: deploy
@@ -79,28 +78,19 @@ jobs:
7978
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
8079
```
8180
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-
9181
### Install packages and deploy
9282
```yaml
9383
- name: Install packages and deploy
94-
uses: serverless/github-action@v3.2
84+
uses: serverless/github-action@v4.0
9585
with:
96-
install-packages: serverless-offline,serverless-prune-plugin
86+
install-packages: serverless-offline serverless-prune-plugin
9787
args: deploy
9888
```
9989
10090
### Use a particular Serverless Framework CLI version
10191
```yaml
10292
- name: Deploy using a particular version of serverless
103-
uses: serverless/github-action@v3.2
93+
uses: serverless/github-action@v4.0
10494
with:
10595
serverless-version: 2
10696
args: deploy
@@ -109,42 +99,17 @@ jobs:
10999
### Change your working directory
110100
```yaml
111101
- name: Deploy from a particular working directory
112-
uses: serverless/github-action@v3.2
102+
uses: serverless/github-action@v4.0
113103
with:
114104
working-directory: ./foo
115105
args: deploy
116106
```
117107
118-
## Usage with serverless plugins
119-
Change your action in this way, according to [this issue](https://github.com/serverless/github-action/issues/28), thanks to @matthewpoer:
120-
```yaml
121-
- name: Install Plugin and Deploy
122-
uses: serverless/[email protected]
123-
with:
124-
args: -c "serverless plugin install --name <plugin-name> && serverless deploy"
125-
entrypoint: /bin/sh
126-
```
127-
128-
## Fix "This command can only be run in a Serverless service directory" error
129-
Change your action in this way, according to [this issue](https://github.com/serverless/github-action/issues/53#issuecomment-1059839383), thanks to @nikhuber:
130-
```yaml
131-
- name: Enter dir and deploy
132-
uses: serverless/[email protected]
133-
with:
134-
args: -c "cd ./<your-dir> && serverless deploy"
135-
entrypoint: /bin/sh
136-
```
137-
138-
139-
## Use serverless v1 or v2
140-
Change the action with one of the following:
108+
## Use a previous version
109+
Change the action with `@{version}`, for example:
141110
```yaml
142-
uses: serverless/github-action@v1
111+
uses: serverless/github-action@v3.2
143112
```
144-
```yaml
145-
uses: serverless/github-action@v2
146-
```
147-
148113

149114
## License
150115

action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ branding:
77
inputs:
88
args:
99
description: 'Arguments passed to `serverless`'
10-
required: true
10+
required: false
11+
default: none
1112
aws-credentials:
1213
description: 'Whether to use credentials stored in the local environment (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)'
1314
required: false
1415
default: 'false'
1516
install-packages:
16-
description: 'Comma-separated list of packages to install prior to running `serverless {args}`'
17+
description: 'Space-separated list of packages to install prior to running `serverless {args}`'
1718
required: false
1819
default: none
1920
serverless-version:

entrypoint.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/sh -l
2+
if [ "$5" = "none" ]; then
3+
echo "You need to specify at least one argument, like `deploy`"
4+
exit 1
5+
fi
6+
27
cd $1
8+
39
npm i -g serverless@$2
410

5-
PACKAGES_TO_INSTALL=$3
6-
if [ $3 != "none" ]; then
7-
npm i -g ${PACKAGES_TO_INSTALL//,/\ }
11+
if [ "$3" != "none" ]; then
12+
npm i -g $3
813
fi
914

1015
WITH_LOCAL_CREDENTIALS=""
11-
if [ $4 = "true" ] || [ $4 = "yes" ]; then
16+
if [ "$4" = "true" ] || [ "$4" = "yes" ]; then
1217
WITH_LOCAL_CREDENTIALS="--use-local-credentials"
1318
fi
1419

0 commit comments

Comments
 (0)