99[ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/f84f0bcb39c9a5c5fb99/maintainability )] ( https://codeclimate.com/github/eclass/semantic-release-ssh-commands/maintainability )
1010[ ![ 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 )
1111
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
1313
1414| Step | Description |
1515| --------------------| ---------------------------------------------------------------------------------------------|
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 . |
1818
1919## Install
2020
@@ -33,7 +33,13 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
3333 " @semantic-release/npm" ,
3434 " @semantic-release/git" ,
3535 " @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+ ]
3743 ]
3844}
3945```
@@ -44,7 +50,17 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
4450
4551| Variable | Description |
4652| -------------------- | ----------------------------------------------------------------- |
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+
4864
4965### Examples
5066
@@ -55,7 +71,13 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
5571 " @semantic-release/npm" ,
5672 " @semantic-release/git" ,
5773 " @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+ ]
5981 ]
6082}
6183```
@@ -65,6 +87,14 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
6587release :
6688 image : node:alpine
6789 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
6898 script :
6999 - npx semantic-release
70100 only :
@@ -88,6 +118,13 @@ jobs:
88118 - stage : test
89119 script : npm t
90120 - 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
91128 script : npx semantic-release
92129
93130```
0 commit comments