9
9
[ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/f84f0bcb39c9a5c5fb99/maintainability )] ( https://codeclimate.com/github/eclass/semantic-release-ssh-commands/maintainability )
10
10
[ ![ semantic-release] ( https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg )] ( https://github.com/semantic-release/semantic-release )
11
11
12
- > [ semantic-release] ( https://github.com/semantic-release/semantic-release ) plugin to deploy app
12
+ > [ semantic-release] ( https://github.com/semantic-release/semantic-release ) plugin to deploy app with ssh commands
13
13
14
14
| Step | Description |
15
15
| --------------------| ---------------------------------------------------------------------------------------------|
16
- | ` verifyConditions ` | Verify the presence of the ` CUSTOM_ENV ` environment variable . |
17
- | ` publish ` | Deploy app. |
16
+ | ` verifyConditions ` | Verify the presence of the ` SSH_USER ` , ` SSH_HOST ` environment variables . |
17
+ | ` publish ` | Deploy app over ssh . |
18
18
19
19
## Install
20
20
@@ -33,7 +33,13 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
33
33
" @semantic-release/npm" ,
34
34
" @semantic-release/git" ,
35
35
" @semantic-release/gitlab" ,
36
- " @eclass/semantic-release-ssh-commands"
36
+ [
37
+ " @eclass/semantic-release-ssh-commands" ,
38
+ {
39
+ "verifyConditionsCmd" : " sh /usr/local/verifyConditionsCmd.sh" ,
40
+ "publishCmd" : " sh /usr/local/publishCmd.sh" ,
41
+ }
42
+ ]
37
43
]
38
44
}
39
45
```
@@ -44,7 +50,17 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
44
50
45
51
| Variable | Description |
46
52
| -------------------- | ----------------------------------------------------------------- |
47
- | ` CUSTOM_ENV ` | A custom env var |
53
+ | ` SSH_USER ` | A ssh user |
54
+ | ` SSH_HOST ` | A ssh host |
55
+ | ` SSH_PRIVATE_KEY ` | Content of private ssh key (Optional) |
56
+
57
+ ### Options
58
+
59
+ | Variable | Description |
60
+ | --------- | ----------------------------------------------------------------- |
61
+ | ` verifyConditionsCmd ` | A command to verificate. Required. Ex: "sh /usr/local/verifyConditionsCmd.sh" |
62
+ | ` publishCmd ` | A command to publish new release. This step inject VERSIOn environment variable to use in you command. Required. Ex: "sh /usr/local/publishCmd.sh" |
63
+
48
64
49
65
### Examples
50
66
@@ -55,7 +71,13 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
55
71
" @semantic-release/npm" ,
56
72
" @semantic-release/git" ,
57
73
" @semantic-release/gitlab" ,
58
- " @eclass/semantic-release-ssh-commands"
74
+ [
75
+ " @eclass/semantic-release-ssh-commands" ,
76
+ {
77
+ "verifyConditionsCmd" : " sh /usr/local/verifyConditionsCmd.sh" ,
78
+ "publishCmd" : " sh /usr/local/publishCmd.sh" ,
79
+ }
80
+ ]
59
81
]
60
82
}
61
83
```
@@ -65,6 +87,14 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
65
87
release :
66
88
image : node:alpine
67
89
stage : release
90
+ before_script :
91
+ - apk add --no-cache git openssh-client
92
+ - mkdir -p /root/.ssh
93
+ - chmod 0700 /root/.ssh
94
+ - ssh-keyscan $SSH_HOST > /root/.ssh/known_hosts
95
+ - echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
96
+ - chmod 600 /root/.ssh/id_rsa
97
+ - echo " IdentityFile /root/.ssh/id_rsa" >> /etc/ssh/ssh_config
68
98
script :
69
99
- npx semantic-release
70
100
only :
@@ -88,6 +118,13 @@ jobs:
88
118
- stage : test
89
119
script : npm t
90
120
- stage : deploy
121
+ addons :
122
+ ssh_known_hosts : $SSH_HOST
123
+ before_deploy :
124
+ - eval "$(ssh-agent -s)"
125
+ - echo "$SSH_PRIVATE_KEY" > /tmp/deploy_rsa
126
+ - chmod 600 /tmp/deploy_rsa
127
+ - ssh-add /tmp/deploy_rsa
91
128
script : npx semantic-release
92
129
93
130
```
0 commit comments