@eclass/semantic-release-ssh-commands
v1.0.3 release semantic-release
@eclass/semantic-release-ssh-commands
semantic-release plugin to deploy app with ssh commands
Step | Description |
---|---|
verifyConditions |
Verify the presence of the SSH_USER , SSH_HOST environment variables. |
publish |
Deploy app over ssh. |
Install
npm i -D @eclass/semantic-release-ssh-commands
Usage
The plugin can be configured in the semantic-release configuration file:
{
"plugins": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/gitlab",
[
"@eclass/semantic-release-ssh-commands",
{
"verifyConditionsCmd": "sh /usr/local/verifyConditionsCmd.sh",
"publishCmd": "sh /usr/local/publishCmd.sh",
}
]
]
}
Configuration
Environment variables
Variable | Description |
---|---|
SSH_USER |
A ssh user |
SSH_HOST |
A ssh host |
SSH_PRIVATE_KEY |
Content of private ssh key (Optional) |
Options
Variable | Description |
---|---|
verifyConditionsCmd |
A command to verificate. Required. Ex: "sh /usr/local/verifyConditionsCmd.sh" |
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" |
Examples
{
"plugins": [
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/git",
"@semantic-release/gitlab",
[
"@eclass/semantic-release-ssh-commands",
{
"verifyConditionsCmd": "sh /usr/local/verifyConditionsCmd.sh",
"publishCmd": "sh /usr/local/publishCmd.sh",
}
]
]
}
# .gitlab-ci.yml
release:
image: node:alpine
stage: release
before_script:
- apk add --no-cache git openssh-client
- mkdir -p /root/.ssh
- chmod 0700 /root/.ssh
- ssh-keyscan $SSH_HOST > /root/.ssh/known_hosts
- echo "$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
- chmod 600 /root/.ssh/id_rsa
- echo " IdentityFile /root/.ssh/id_rsa" >> /etc/ssh/ssh_config
script:
- npx semantic-release
only:
- master
# .travis.yml
language: node_js
cache:
directories:
- ~/.npm
node_js:
- "12"
stages:
- test
- name: deploy
if: branch = master
jobs:
include:
- stage: test
script: npm t
- stage: deploy
addons:
ssh_known_hosts: $SSH_HOST
before_deploy:
- eval "$(ssh-agent -s)"
- echo "$SSH_PRIVATE_KEY" > /tmp/deploy_rsa
- chmod 600 /tmp/deploy_rsa
- ssh-add /tmp/deploy_rsa
script: npx semantic-release
License
npm i @eclass/semantic-release-ssh-commands
Metadata
- MIT
- >=10
- Leonardo Gatica
- released 8/26/2020