Skip to content

Commit 6587792

Browse files
committed
doc: add documentation for v1
1 parent a4d7696 commit 6587792

File tree

1 file changed

+149
-35
lines changed

1 file changed

+149
-35
lines changed

README.md

Lines changed: 149 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,155 @@
11
# Action to manage GitHub deployments
22

3-
## Usage - create deployment
3+
Features:
4+
- create a deployment (and invalidate all previous deployments)
5+
- finish a deployment (with success/failure state)
6+
- delete all deployments in specific environment
7+
- delete a deployment by id
48

5-
### Inputs
9+
## Usage
610

7-
#### `type`
11+
### create
812

9-
**Required** type of the defined action. Should be `create` to create a deployment.
13+
Inputs:
1014

11-
### Outputs
15+
parameter | description
16+
- | -
17+
`token`|**Required** token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo
18+
`type`|**Required** type of an action. Should be `create` to create a deployment
19+
`logs`|url to the deployment logs
20+
`environment`|environment to create a deployments in, default to `context.ref` without prefixes (`'refs/heads/'`, `'deploy-'`), i.e. branch name
21+
`environment_url`|link to the deployed application
22+
`description`| optional description, defaults to `"deployed by $context.actor"`
1223

13-
#### `deployment_id`
24+
Outputs:
1425

15-
The if of the created deployment.
26+
output | description
27+
- | -
28+
`deployment_id` | The `id` of the created deployment
1629

17-
## Example usage
30+
#### Example usage
1831

1932
```yaml
20-
uses: npm/action-deploy@master
21-
with:
22-
type: 'create'
23-
token: ${{github.token}}
24-
logs: 'http://your-app.com/deployment_logs'
25-
environment: 'staging'
26-
environment_url: 'http://staging.your-app.com'
33+
- name: create a deployment
34+
uses: npm/action-deploy@v1
35+
with:
36+
type: create
37+
token: ${{github.token}}
38+
logs: https://your-app.com/deployment_logs
39+
environment: staging
40+
environment_url: https://staging.your-app.com
41+
```
42+
43+
### finish
44+
45+
Given in one of the previous steps you created a deployment, with `finish` you can set a status upon a deployment completion
46+
47+
Inputs:
48+
49+
parameter | description
50+
- | -
51+
`token` | **Required** token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo
52+
`type` | **Required** type of an action. Should be `finish`
53+
`deployment_id` | **Required** the `id` of the a deployment to finish
54+
`status` | can be any status, e.g. failure/success
55+
56+
Outputs: none
57+
58+
#### Example usage
59+
60+
```yaml
61+
- name: create a deployment
62+
uses: npm/action-deploy@v1
63+
id: create-deployment
64+
with:
65+
type: create
66+
token: ${{github.token}}
67+
logs: https://your-app.com/deployment_logs
68+
environment: staging
69+
environment_url: https://staging.your-app.com
70+
71+
# add your deployment steps here
72+
- name: placeholder for actual deployment
73+
run: sleep 10s
74+
75+
- name: finish deployment
76+
uses: npm/action-deploy@v1
77+
with:
78+
type: finish
79+
token: ${{github.token}}
80+
status: success
81+
deployment_id: ${{steps.create-deployment.outputs.deployment_id}}
82+
```
83+
84+
### delete-all
85+
86+
Allows deleting all deployments for a specific environment
87+
88+
Inputs:
89+
90+
parameter | description
91+
- | -
92+
`token` | **Required** token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo
93+
`type` | **Required** type of an action. Should be `delete-all`
94+
`environment` | environment to delete all deployments in
95+
96+
Outputs: none
97+
98+
#### Example usage
99+
100+
```yaml
101+
- name: delete all deployments in staging
102+
uses: npm/action-deploy@v1
103+
with:
104+
type: delete-all
105+
token: ${{github.token}}
106+
environment: staging
107+
```
108+
109+
### delete
110+
111+
Given in one of the previous steps you created a deployment, with `delete` you can delete it by id
112+
113+
Inputs:
114+
115+
parameter | description
116+
- | -
117+
`token` | **Required** token to authorize calls to GitHub API, can be ${{github.token}} to create a deployment for the same repo
118+
`type` | **Required** type of an action. Should be `delete`
119+
`deployment_id` | **Required** the `id` of the a deployment to delete
120+
121+
Outputs: none
122+
123+
#### Example usage
124+
125+
```yaml
126+
- name: create a deployment
127+
uses: npm/action-deploy@v1
128+
id: create-deployment
129+
with:
130+
type: create
131+
token: ${{github.token}}
132+
logs: https://your-app.com/deployment_logs
133+
environment: staging
134+
environment_url: https://staging.your-app.com
135+
136+
# add your deployment steps here
137+
- name: placeholder for actual deployment
138+
run: sleep 10s
139+
140+
- name: delete deployment
141+
uses: npm/action-deploy@v1
142+
with:
143+
type: delete
144+
token: ${{github.token}}
145+
deployment_id: ${{steps.create-deployment.outputs.deployment_id}}
27146
```
28147

29148
## Development
30149

31150
### Prerequisites
32151

33-
Install the dependencies
152+
Install the dependencies
34153
```bash
35154
$ npm install
36155
```
@@ -40,23 +159,16 @@ Build the typescript and package it for distribution
40159
$ npm run build && npm run pack
41160
```
42161

43-
Run the tests :heavy_check_mark:
162+
Run the tests :heavy_check_mark:
44163
```bash
45-
$ npm test
46-
47-
PASS ./index.test.js
48-
✓ throws invalid number (3ms)
49-
wait 500 ms (504ms)
50-
test runs (95ms)
51-
52-
...
164+
$ npm run build && npm test
53165
```
54166

55-
### Change action.yml
167+
### Update action.yml
56168

57169
The action.yml contains defines the inputs and output for your action.
58170

59-
Update the action.yml with your name, description, inputs and outputs for your action.
171+
Update the action.yml with description, inputs and outputs for your action.
60172

61173
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
62174

@@ -69,9 +181,9 @@ import * as core from '@actions/core';
69181
...
70182
71183
async function run() {
72-
try {
184+
try {
73185
...
74-
}
186+
}
75187
catch (error) {
76188
core.setFailed(error.message);
77189
}
@@ -84,7 +196,7 @@ See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/R
84196

85197
## Publish to a distribution branch
86198

87-
Actions are run from GitHub repos so we will checkin the packed dist folder.
199+
Actions are run from GitHub repos so we will checkin the packed dist folder.
88200

89201
Then run [ncc](https://github.com/zeit/ncc) and push the results:
90202
```bash
@@ -94,7 +206,7 @@ $ git commit -a -m "prod dependencies"
94206
$ git push origin releases/v1
95207
```
96208

97-
Your action is now published! :rocket:
209+
Your action is now published! :rocket:
98210

99211
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
100212

@@ -103,13 +215,15 @@ See the [versioning documentation](https://github.com/actions/toolkit/blob/maste
103215
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)])
104216

105217
```yaml
106-
uses: ./
107-
with:
108-
milliseconds: 1000
218+
- uses: ./
219+
name: Delete all deployments
220+
with:
221+
token: ${{github.token}}
222+
type: delete-all
109223
```
110224

111225
See the [actions tab](https://github.com/npm/action-deploy/actions) for runs of this action! :rocket:
112226

113-
## Usage:
227+
## Deploy
114228

115229
After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action

0 commit comments

Comments
 (0)