1
1
# Action to manage GitHub deployments
2
2
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
4
8
5
- ### Inputs
9
+ ## Usage
6
10
7
- #### ` type `
11
+ ### create
8
12
9
- ** Required ** type of the defined action. Should be ` create ` to create a deployment.
13
+ Inputs:
10
14
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" `
12
23
13
- #### ` deployment_id `
24
+ Outputs:
14
25
15
- The if of the created deployment.
26
+ output | description
27
+ - | -
28
+ ` deployment_id ` | The ` id ` of the created deployment
16
29
17
- ## Example usage
30
+ #### Example usage
18
31
19
32
``` 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}}
27
146
` ` `
28
147
29
148
# # Development
30
149
31
150
# ## Prerequisites
32
151
33
- Install the dependencies
152
+ Install the dependencies
34
153
` ` ` bash
35
154
$ npm install
36
155
` ` `
@@ -40,23 +159,16 @@ Build the typescript and package it for distribution
40
159
$ npm run build && npm run pack
41
160
` ` `
42
161
43
- Run the tests :heavy_check_mark :
162
+ Run the tests :heavy_check_mark :
44
163
` ` ` 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
53
165
` ` `
54
166
55
- ### Change action.yml
167
+ # ## Update action.yml
56
168
57
169
The action.yml contains defines the inputs and output for your action.
58
170
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.
60
172
61
173
See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
62
174
@@ -69,9 +181,9 @@ import * as core from '@actions/core';
69
181
...
70
182
71
183
async function run() {
72
- try {
184
+ try {
73
185
...
74
- }
186
+ }
75
187
catch (error) {
76
188
core.setFailed(error.message);
77
189
}
@@ -84,7 +196,7 @@ See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/R
84
196
85
197
# # Publish to a distribution branch
86
198
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.
88
200
89
201
Then run [ncc](https://github.com/zeit/ncc) and push the results :
90
202
` ` ` bash
@@ -94,7 +206,7 @@ $ git commit -a -m "prod dependencies"
94
206
$ git push origin releases/v1
95
207
` ` `
96
208
97
- Your action is now published! :rocket :
209
+ Your action is now published! :rocket :
98
210
99
211
See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)
100
212
@@ -103,13 +215,15 @@ See the [versioning documentation](https://github.com/actions/toolkit/blob/maste
103
215
You can now validate the action by referencing `./` in a workflow in your repo (see [test.yml](.github/workflows/test.yml)])
104
216
105
217
` ` ` 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
109
223
` ` `
110
224
111
225
See the [actions tab](https://github.com/npm/action-deploy/actions) for runs of this action! :rocket :
112
226
113
- ## Usage:
227
+ # # Deploy
114
228
115
229
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