Compare commits

...

106 Commits

Author SHA1 Message Date
github-actions
c711f2c339 chore(release): 2.2.11 [skip ci]
## [2.2.11](https://github.com/easingthemes/ssh-deploy/compare/v2.2.10...v2.2.11) (2021-05-28)

### Bug Fixes

* remove change npm to public ([3c36af7](3c36af7577))
2021-05-28 00:23:46 +00:00
Dragan Filipović
824072bc5a Merge pull request #60 from easingthemes/feature/package-json-automation-6
fix: remove change npm to public
2021-05-28 02:22:56 +02:00
Dragan Filipovic
3c36af7577 fix: remove change npm to public 2021-05-28 02:22:36 +02:00
github-actions
649339f4bb chore(release): 2.2.10 [skip ci]
## [2.2.10](https://github.com/easingthemes/ssh-deploy/compare/v2.2.9...v2.2.10) (2021-05-27)

### Bug Fixes

* add assets to semantic-release git ([0867b12](0867b12954))
2021-05-27 23:24:30 +00:00
Dragan Filipović
66e6843055 Merge pull request #59 from easingthemes/feature/package-json-automation-5
fix: add assets to semantic-release git
2021-05-28 01:23:43 +02:00
Dragan Filipovic
0867b12954 fix: add assets to semantic-release git 2021-05-28 01:23:17 +02:00
github-actions
d71ce0f0b2 chore(release): 2.2.9 [skip ci]
## [2.2.9](https://github.com/easingthemes/ssh-deploy/compare/v2.2.8...v2.2.9) (2021-05-27)

### Bug Fixes

* change npm to public ([191c82d](191c82d9b4))
2021-05-27 22:38:16 +00:00
Dragan Filipović
382db98e53 Merge pull request #58 from easingthemes/feature/package-json-automation-4
fix: change npm to public
2021-05-28 00:37:29 +02:00
Dragan Filipovic
191c82d9b4 fix: change npm to public 2021-05-28 00:37:06 +02:00
github-actions
5109c975e9 chore(release): 2.2.8 [skip ci]
## [2.2.8](https://github.com/easingthemes/ssh-deploy/compare/v2.2.7...v2.2.8) (2021-05-27)

### Bug Fixes

* update npm package name ([9c4e411](9c4e4119ad))
2021-05-27 22:33:51 +00:00
Dragan Filipović
76882263e5 Merge pull request #57 from easingthemes/feature/package-json-automation-3
fix: update npm package name
2021-05-28 00:33:13 +02:00
Dragan Filipovic
9c4e4119ad fix: update npm package name 2021-05-28 00:32:37 +02:00
github-actions
fbeaefca08 chore(release): 2.2.7 [skip ci]
## [2.2.7](https://github.com/easingthemes/ssh-deploy/compare/v2.2.6...v2.2.7) (2021-05-27)

### Bug Fixes

* minify dist ([87551c3](87551c3893))
2021-05-27 22:24:50 +00:00
Dragan Filipović
f04642c1f5 Merge pull request #56 from easingthemes/feature/package-json-automation-2
Feature/package json automation 2
2021-05-28 00:24:06 +02:00
Dragan Filipovic
fdf6057d5e ci: try package.json npm enabled 2021-05-28 00:23:28 +02:00
Dragan Filipovic
87551c3893 fix: minify dist 2021-05-28 00:23:04 +02:00
github-actions
83d848a9e4 chore(release): 2.2.6 [skip ci]
## [2.2.6](https://github.com/easingthemes/ssh-deploy/compare/v2.2.5...v2.2.6) (2021-05-27)

### Bug Fixes

* add NPM token ([2197bc6](2197bc60ef))
2021-05-27 22:02:20 +00:00
Dragan Filipović
9c02ed6208 Merge pull request #55 from easingthemes/feature/package-json-automation-1
fix: add NPM token
2021-05-28 00:01:28 +02:00
Dragan Filipovic
2197bc60ef fix: add NPM token 2021-05-27 23:57:27 +02:00
github-actions
eb4a19604b chore(release): 2.2.5 [skip ci]
## [2.2.5](https://github.com/easingthemes/ssh-deploy/compare/v2.2.4...v2.2.5) (2021-05-27)

### Bug Fixes

* semantic-release/npm update config ([40096bf](40096bf224))
2021-05-27 21:40:47 +00:00
Dragan Filipović
09342ca039 Merge pull request #54 from easingthemes/feature/package-json-automation
fix: semantic-release/npm update config
2021-05-27 23:40:02 +02:00
Dragan Filipovic
40096bf224 fix: semantic-release/npm update config 2021-05-27 23:39:43 +02:00
github-actions
4383250122 chore(release): 2.2.4 [skip ci]
## [2.2.4](https://github.com/easingthemes/ssh-deploy/compare/v2.2.3...v2.2.4) (2021-05-27)

### Bug Fixes

* add branch instead of a version in a readme ([8218c8e](8218c8ed95))
2021-05-27 21:35:25 +00:00
Dragan Filipović
142b71c9e1 Merge pull request #53 from easingthemes/feature/readme-update
fix: add branch instead of a version in a readme
2021-05-27 23:34:31 +02:00
Dragan Filipovic
8218c8ed95 fix: add branch instead of a version in a readme 2021-05-27 23:33:55 +02:00
github-actions
b75a6aac49 chore(release): 2.2.3 [skip ci]
## [2.2.3](https://github.com/easingthemes/ssh-deploy/compare/v2.2.2...v2.2.3) (2021-05-27)

### Bug Fixes

* codeql yaml syntax update ([87ad671](87ad6713b5))
2021-05-27 21:20:23 +00:00
Dragan Filipović
a0be71d296 Merge pull request #52 from easingthemes/feature/codeql-fix
fix: codeql yaml syntax update
2021-05-27 23:19:39 +02:00
Dragan Filipovic
87ad6713b5 fix: codeql yaml syntax update 2021-05-27 23:16:38 +02:00
github-actions
b12dcbe93c chore(release): 2.2.2 [skip ci]
## [2.2.2](https://github.com/easingthemes/ssh-deploy/compare/v2.2.1...v2.2.2) (2021-05-27)

### Bug Fixes

* codeql build ([5e456a4](5e456a475a))
2021-05-27 21:14:04 +00:00
Dragan Filipović
c984a47bf5 Merge pull request #51 from easingthemes/feature/codeql-fix
fix: codeql build
2021-05-27 23:13:23 +02:00
Dragan Filipovic
5e456a475a fix: codeql build 2021-05-27 23:12:03 +02:00
github-actions
a9eda89ad7 chore(release): 2.2.1 [skip ci]
## [2.2.1](https://github.com/easingthemes/ssh-deploy/compare/v2.2.0...v2.2.1) (2021-05-27)

### Bug Fixes

* add package json auto updates ([ce56d75](ce56d75fc1))
2021-05-27 21:08:10 +00:00
Dragan Filipović
3cfa1cdc25 Merge pull request #50 from easingthemes/feature/release-npm-update
fix: add package json auto updates
2021-05-27 23:07:30 +02:00
Dragan Filipovic
ce56d75fc1 fix: add package json auto updates 2021-05-27 23:06:40 +02:00
github-actions
74b3a2aba4 chore(release): 2.2.0 [skip ci]
# [2.2.0](https://github.com/easingthemes/ssh-deploy/compare/v2.1.7...v2.2.0) (2021-05-27)

### Bug Fixes

* only=prod package json ([95f4dc8](95f4dc8069))
* replace i with ci ([50d1f57](50d1f576f9))
* update ncc ([20a0cae](20a0cae1ae))
* update plugins ([b2adc00](b2adc00c92))
* update plugins ([a50a999](a50a999528))

### Features

* add semantic-release-action ([ac3c9b5](ac3c9b51d5))
2021-05-27 21:00:10 +00:00
Dragan Filipović
77bfc8c169 Merge pull request #49 from easingthemes/feature/release-ci-update
feat: add semantic-release-action
2021-05-27 22:59:32 +02:00
Dragan Filipovic
ac3c9b51d5 feat: add semantic-release-action 2021-05-27 22:56:27 +02:00
Dragan Filipović
a0be893c82 Merge pull request #48 from easingthemes/feature/dependencies-update
Feature/dependencies update
2021-05-27 22:38:28 +02:00
Dragan Filipovic
50d1f576f9 fix: replace i with ci 2021-05-27 22:08:42 +02:00
Dragan Filipovic
20a0cae1ae fix: update ncc 2021-05-27 22:04:06 +02:00
Dragan Filipovic
95f4dc8069 fix: only=prod package json 2021-05-27 22:03:15 +02:00
Dragan Filipovic
b2adc00c92 fix: update plugins 2021-05-27 21:51:19 +02:00
Dragan Filipovic
a50a999528 fix: update plugins 2021-05-27 21:51:10 +02:00
github-actions
1242867d7a 2.1.9 2021-04-16 23:24:55 +00:00
Dragan Filipovic
33648ba2ca CI - test tags 2021-04-17 01:03:01 +02:00
github-actions
40a3789c05 2.1.8 2021-04-16 22:56:33 +00:00
github-actions
7e2c0f29d6 2.1.7 2021-04-16 22:41:08 +00:00
Dragan Filipovic
e9c43c6900 CI - use ci instead of install 2021-04-17 00:39:39 +02:00
Dragan Filipovic
9ae3c340cb CI add git user data 2021-04-17 00:36:22 +02:00
Dragan Filipovic
386c8766a0 CI - split git commands 2021-04-17 00:28:36 +02:00
Dragan Filipovic
130901534a CI - typo fix 2021-04-17 00:24:54 +02:00
Dragan Filipovic
8b977327bb CI - split git commands 2021-04-17 00:22:34 +02:00
Dragan Filipović
880f3b6b88 Merge pull request #43 from easingthemes/feature/CI-add-tag-action
Feature/ci add tag action
2021-04-17 00:18:03 +02:00
Dragan Filipovic
ec4a00fe02 CI - typo fix 2021-04-17 00:17:27 +02:00
Dragan Filipovic
a04c641775 CI - add steps names 2021-04-17 00:12:22 +02:00
Dragan Filipovic
9483c83d88 CI fix input vars 2021-04-17 00:08:19 +02:00
Dragan Filipovic
e41d593e15 CI add actions for build and tag 2021-04-17 00:06:00 +02:00
Dragan Filipović
9ab3993555 Merge pull request #35 from easingthemes/feature/RSYNC-exclude-option
RSYNC use excludeFirst instead of exclude
2021-03-24 18:50:40 +01:00
Dragan Filipovic
07265c8c95 RSYNC use excludeFirst instead of exclude 2021-03-24 18:48:12 +01:00
Dragan Filipović
a27b8667de Merge pull request #32 from peterkracik/master
Exclude folder parameter
2021-03-15 09:54:06 +01:00
Peter Kracik
2b38f7bf7a Added exclude parameter 2021-03-12 07:42:12 +01:00
Peter Kracik
cd3b869a28 Update action.yml 2021-03-12 07:26:41 +01:00
Dragan Filipovic
191986574c [DOCS] Readme update 2020-09-18 23:35:33 +02:00
Dragan Filipovic
d41b136666 [BUILD] rebuild 2020-09-18 23:31:43 +02:00
Dragan Filipovic
1ac1bcb558 [VERSION] version bump 2020-09-18 23:31:31 +02:00
Dragan Filipovic
c14eb85faf [DOCS] Readme update 2020-09-18 23:29:28 +02:00
Dragan Filipovic
2bc5e10d4d [Formatting] formatting updates 2020-09-18 23:26:31 +02:00
Dragan Filipović
4f928a3efc Merge pull request #15 from easingthemes/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-08-16 22:52:37 +02:00
dependabot[bot]
aac4cbf0db Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-21 08:46:30 +00:00
Dragan Filipovic
4042d3876f [build] update package lock 2020-07-01 01:01:48 +02:00
Dragan Filipovic
68f9da66f0 [version] prepare rc.1 2020-07-01 00:56:10 +02:00
Dragan Filipovic
073bd0b6f6 [build] rebuild 2020-07-01 00:54:42 +02:00
Dragan Filipovic
14eb503e62 [action] get input vars from ENV or WITH workflow settings 2020-07-01 00:54:24 +02:00
Dragan Filipovic
a9e37f3cb5 [version] increase version 2020-07-01 00:20:13 +02:00
Dragan Filipović
ff615959b6 Merge pull request #11 from aperezdc/master
action.yml: Add mising declaration for the ARGS parameter
2020-07-01 00:17:59 +02:00
Adrian Perez de Castro
5c4b90e3f8 action.yml: Add mising declaration for the ARGS parameter 2020-06-30 23:03:20 +03:00
Dragan Filipović
66b3ffb0f7 Merge pull request #10 from easingthemes/9-Readme-update-ssh-keys
#9 Add link to more info about SSH keys
2020-06-29 21:10:59 +02:00
Dragan Filipovic
037d157977 #9 Add link to more info about SSH keys 2020-06-29 21:09:04 +02:00
Dragan Filipović
e34308df6c Merge pull request #6 from perlun/patch-1
README.md: fix typo
2020-06-15 22:03:58 +02:00
Per Lundberg
ad838db71f README.md: fix typo 2020-06-06 23:36:28 +03:00
Dragan Filipovic
7f1c0e0111 [docs] Update version naming 2020-04-11 23:20:56 +02:00
Dragan Filipovic
54f2361d27 [docs] Update readme 2020-04-11 23:08:36 +02:00
Dragan Filipovic
101b6c13a0 [code] hotfix dist 2020-04-11 17:44:56 +02:00
Dragan Filipovic
ac4f0895a6 [code] hotfix 2020-04-11 17:42:37 +02:00
Dragan Filipović
0711330570 Merge pull request #5 from easingthemes/feature/SSH-DEPLOY-refactor
Feature/ssh deploy refactor
2020-04-11 17:25:18 +02:00
Dragan Filipovic
62063532be Merge branch 'master' into feature/SSH-DEPLOY-refactor
# Conflicts:
#	.gitignore
#	README.md
#	dist/index.js
#	src/index.js
2020-04-11 16:54:21 +02:00
Dragan Filipović
1a29114d7b Merge pull request #4 from GarryOne/patch-1
Improved error handling. Added to README.md PM key generation details
2020-04-11 16:40:33 +02:00
Dragan Filipovic
e23436526e [readme] update Readme 2020-04-11 16:33:22 +02:00
Dragan Filipovic
bf3218eb12 [readme] update Readme 2020-04-11 16:30:28 +02:00
Dragan Filipovic
7269cb396a [dist] rebuild 2020-04-11 16:30:11 +02:00
Dragan Filipovic
460751d7c3 [code] split helpers into separate files 2020-04-11 16:29:20 +02:00
Dragan Filipovic
9cdc72374b [action] add required params 2020-04-11 16:27:09 +02:00
Dragan Filipovic
19689edd76 [tests] add editorconfig and eslint 2020-04-11 16:26:19 +02:00
Mardari Igor
53c00dce2b Update README.md 2020-04-11 13:11:34 +03:00
GarryOne
140e959df8 Added key generation details to README.md 2020-03-27 01:17:37 +02:00
GarryOne
00e4d7e856 Added cmd to rsync error output 2020-03-27 01:10:01 +02:00
GarryOne
37e21b5b6b Added error display for rsync 2020-03-27 00:05:33 +02:00
GarryOne
19dbe22d4f Removed console.log 2020-03-26 23:47:55 +02:00
GarryOne
733f9fc153 Added console.log(process.env) 2020-03-26 23:27:22 +02:00
GarryOne
749cc36d5d Added .idea to .gitignore 2020-03-25 05:33:08 +02:00
GarryOne
f09a8d0277 Removed console.log() 2020-03-25 05:28:27 +02:00
GarryOne
82ccbba7dc Added field key to validation message 2020-03-25 05:20:29 +02:00
GarryOne
ff832e4e77 Built src/index.js 2020-03-25 05:08:01 +02:00
Mardari Igor
3f84fa4ae1 Set ssh to false 2020-03-25 04:50:26 +02:00
Dragan Filipović
c28aa7215e Merge pull request #3 from JZLeung/patch-1
fix: 修复 ARGS 为空时导致 rsync 执行错误问题。
2020-03-24 00:04:15 +01:00
Leung-JZ
caaa95b651 fix: 修复 ARGS 为空时导致 rsync 执行错误问题。
由于 ARGS 非必填,当其为空时,报错:

⚠️ An error happened:(. Cannot read property 'match' of undefined TypeError: Cannot read property 'match' of undefined
2020-03-12 09:16:23 +08:00
19 changed files with 2229 additions and 820 deletions

11
.editorconfig Normal file
View File

@@ -0,0 +1,11 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true

25
.eslintrc.js Normal file
View File

@@ -0,0 +1,25 @@
module.exports = {
env: {
commonjs: true,
es6: true,
node: true
},
extends: [
'airbnb-base'
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
"comma-dangle": [
"error",
"never"
],
"no-console": "off",
"object-curly-newline": "off"
}
};

31
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Build
on:
push:
branches: [ '**' ]
pull_request:
branches: [ $default-branch ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [14.x]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build
- name: Run Tests
run: npm test --if-present

47
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,47 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '20 12 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
steps:
- name: Checkout
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- run: |
npm ci
npm run build --if-present
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

44
.github/workflows/manual-release.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: Manual Release
on:
workflow_dispatch:
inputs:
dryrun:
description: 'DryRUn'
required: true
default: 'false'
jobs:
release:
name: Test, Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 14.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix['node-version'] }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
- name: Release
uses: cycjimmy/semantic-release-action@v2
with:
dry_run: ${{ github.event.inputs.dryrun == 'true' }}
extra_plugins: |
@semantic-release/changelog@3.0.0
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: github-actions@github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: github-actions@github.com
CI: true

44
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,44 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Test, Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 14.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix['node-version'] }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
- name: Release
uses: cycjimmy/semantic-release-action@v2
with:
dry_run: false
extra_plugins: |
@semantic-release/changelog@3.0.0
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: github-actions@github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: github-actions@github.com
CI: true

2
.gitignore vendored
View File

@@ -17,3 +17,5 @@ node_modules/
.env .env
.env.test .env.test
# IDE
.idea

22
.releaserc Normal file
View File

@@ -0,0 +1,22 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
["@semantic-release/npm", {
"npmPublish": false
}],
[
"@semantic-release/git",
{
"assets": ["docs/CHANGELOG.md", "package.json"]
}
]
]
}

View File

@@ -12,39 +12,55 @@ This action would usually follow a build/test action which leaves deployable cod
Pass configuration with `env` vars Pass configuration with `env` vars
1. `SSH_PRIVATE_KEY` [required] ##### 1. `SSH_PRIVATE_KEY` [required]
This should be the private key part of an ssh key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment. Private key part of an SSH key pair.
The public key part should be added to the `authorized_keys` file on the server that receives the deployment.
2. `REMOTE_HOST` [required] More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication
The keys should be generated using the PEM format. You can use this command
```
ssh-keygen -m PEM -t rsa -b 4096
```
##### 2. `REMOTE_HOST` [required]
eg: mydomain.com eg: mydomain.com
3. `REMOTE_USER` [required] ##### 3. `REMOTE_USER` [required]
eg: myusername eg: myusername
3. `REMOTE_PORT` (optional, default '22') ##### 4. `REMOTE_PORT` (optional, default '22')
eg: '59184' eg: '59184'
2. `ARGS` (optional, default '-rltgoDzvO') ##### 5. `ARGS` (optional, default '-rltgoDzvO')
For any initial/required rsync flags, eg: `-avzr --delete` For any initial/required rsync flags, eg: `-avzr --delete`
3. `SOURCE` (optional, default '') ##### 6. `SOURCE` (optional, default '')
The source directory, path relative to `$GITHUB_WORKSPACE` root, eg: `dist/` The source directory, path relative to `$GITHUB_WORKSPACE` root, eg: `dist/`
4. `TARGET` (optional, default '/home/REMOTE_USER/') ##### 7. `TARGET` (optional, default '/home/REMOTE_USER/')
The target directory The target directory
##### 8. `EXCLUDE` (optional, default '')
path to exclude separated by `,`, ie: `/dist/, /node_modules/`
# Usage # Usage
Use the latest version from Marketplace,eg: ssh-deploy@v2
or use the latest version from a branch, eg: ssh-deploy@main
``` ```
- name: Deploy to Staging server - name: Deploy to Staging server
uses: easingthemes/ssh-deploy@v2.0.7 uses: easingthemes/ssh-deploy@main
env: env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO" ARGS: "-rltgoDzvO"
@@ -52,6 +68,7 @@ The target directory
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }} REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }} TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
``` ```
# Example usage in workflow # Example usage in workflow
@@ -77,7 +94,7 @@ jobs:
- name: Run build task - name: Run build task
run: npm run build --if-present run: npm run build --if-present
- name: Deploy to Server - name: Deploy to Server
uses: easingthemes/ssh-deploy@v2.0.7 uses: easingthemes/ssh-deploy@main
env: env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }} SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete" ARGS: "-rltgoDzvO --delete"
@@ -85,10 +102,9 @@ jobs:
REMOTE_HOST: ${{ secrets.REMOTE_HOST }} REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }} REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }} TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
``` ```
## Disclaimer ## Disclaimer
If you're using GitHub Actions, you'll probably already know that it's still in limited public beta, and GitHub advise against using Actions in production. Check your keys. Check your deployment paths. And use at your own risk.
So, check your keys. Check your deployment paths. And use at your own risk.

View File

@@ -13,13 +13,24 @@ inputs:
required: true required: true
REMOTE_PORT: REMOTE_PORT:
description: "Remote port" description: "Remote port"
required: false
default: "22" default: "22"
SOURCE: SOURCE:
description: "Source directory" description: "Source directory"
required: false
default: "" default: ""
TARGET: TARGET:
description: "Target directory" description: "Target directory"
required: false
default: "/home/REMOTE_USER/" default: "/home/REMOTE_USER/"
ARGS:
description: "Arguments to pass to rsync"
required: false
default: "-rltgoDzvO"
EXCLUDE:
description: "An array of folder to exclude"
required: false
default: ""
outputs: outputs:
status: status:
description: "Status" description: "Status"

648
dist/index.js vendored

File diff suppressed because one or more lines are too long

92
docs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,92 @@
## [2.2.11](https://github.com/easingthemes/ssh-deploy/compare/v2.2.10...v2.2.11) (2021-05-28)
### Bug Fixes
* remove change npm to public ([3c36af7](https://github.com/easingthemes/ssh-deploy/commit/3c36af7577e5aee231cea5a01bb6cc83717d0e74))
## [2.2.10](https://github.com/easingthemes/ssh-deploy/compare/v2.2.9...v2.2.10) (2021-05-27)
### Bug Fixes
* add assets to semantic-release git ([0867b12](https://github.com/easingthemes/ssh-deploy/commit/0867b12954dee2b8a2cccb7dfea3b8f3aa62d679))
## [2.2.9](https://github.com/easingthemes/ssh-deploy/compare/v2.2.8...v2.2.9) (2021-05-27)
### Bug Fixes
* change npm to public ([191c82d](https://github.com/easingthemes/ssh-deploy/commit/191c82d9b441e26cf43f81041376dbf5ecdc1647))
## [2.2.8](https://github.com/easingthemes/ssh-deploy/compare/v2.2.7...v2.2.8) (2021-05-27)
### Bug Fixes
* update npm package name ([9c4e411](https://github.com/easingthemes/ssh-deploy/commit/9c4e4119ad64792e5435e4dbe574c56a3e70839c))
## [2.2.7](https://github.com/easingthemes/ssh-deploy/compare/v2.2.6...v2.2.7) (2021-05-27)
### Bug Fixes
* minify dist ([87551c3](https://github.com/easingthemes/ssh-deploy/commit/87551c38936fc91c0fbe3346ca43319d8098ac09))
## [2.2.6](https://github.com/easingthemes/ssh-deploy/compare/v2.2.5...v2.2.6) (2021-05-27)
### Bug Fixes
* add NPM token ([2197bc6](https://github.com/easingthemes/ssh-deploy/commit/2197bc60ef7870d4bd494966b314eabec1615bd7))
## [2.2.5](https://github.com/easingthemes/ssh-deploy/compare/v2.2.4...v2.2.5) (2021-05-27)
### Bug Fixes
* semantic-release/npm update config ([40096bf](https://github.com/easingthemes/ssh-deploy/commit/40096bf22459d1dd82172d2bd20c0c149e70b1e1))
## [2.2.4](https://github.com/easingthemes/ssh-deploy/compare/v2.2.3...v2.2.4) (2021-05-27)
### Bug Fixes
* add branch instead of a version in a readme ([8218c8e](https://github.com/easingthemes/ssh-deploy/commit/8218c8ed9514d772933e1ab4d1c725a7c05e149f))
## [2.2.3](https://github.com/easingthemes/ssh-deploy/compare/v2.2.2...v2.2.3) (2021-05-27)
### Bug Fixes
* codeql yaml syntax update ([87ad671](https://github.com/easingthemes/ssh-deploy/commit/87ad6713b53d454bd7ad6c4576cea7b2e3e2f4f3))
## [2.2.2](https://github.com/easingthemes/ssh-deploy/compare/v2.2.1...v2.2.2) (2021-05-27)
### Bug Fixes
* codeql build ([5e456a4](https://github.com/easingthemes/ssh-deploy/commit/5e456a475a15096d08ccd2aff2734b3f1250b308))
## [2.2.1](https://github.com/easingthemes/ssh-deploy/compare/v2.2.0...v2.2.1) (2021-05-27)
### Bug Fixes
* add package json auto updates ([ce56d75](https://github.com/easingthemes/ssh-deploy/commit/ce56d75fc1b62a99d72ffba70dcb24fcc3b6b3df))
# [2.2.0](https://github.com/easingthemes/ssh-deploy/compare/v2.1.7...v2.2.0) (2021-05-27)
### Bug Fixes
* only=prod package json ([95f4dc8](https://github.com/easingthemes/ssh-deploy/commit/95f4dc8069045c1f5f726e00cb519b46e4f14267))
* replace i with ci ([50d1f57](https://github.com/easingthemes/ssh-deploy/commit/50d1f576f95c0d7e8ce99fb1b2ab68b2594973e5))
* update ncc ([20a0cae](https://github.com/easingthemes/ssh-deploy/commit/20a0cae1ae81bcc430507363e800342976307a81))
* update plugins ([b2adc00](https://github.com/easingthemes/ssh-deploy/commit/b2adc00c92f129aef41ae46441411c2bebc0dbe4))
* update plugins ([a50a999](https://github.com/easingthemes/ssh-deploy/commit/a50a999528b503846cc7fdf26210f710bd95565a))
### Features
* add semantic-release-action ([ac3c9b5](https://github.com/easingthemes/ssh-deploy/commit/ac3c9b51d5cb52f4add40e2fc2dcc5e970153afc))

1663
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,29 @@
{ {
"name": "ssh-deploy", "name": "@draganfilipovic/ssh-deploy",
"version": "2.1.0", "version": "2.2.11",
"description": "This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.", "description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
"main": "src/index.js", "main": "dist/index.js",
"files": [
"/dist",
"./action.yml",
"./README.md",
"LICENSE"
],
"dependencies": { "dependencies": {
"command-exists": "1.2.8", "command-exists": "1.2.9",
"node-cmd": "3.0.0", "node-cmd": "4.0.0",
"rsyncwrapper": "3.0.1" "rsyncwrapper": "3.0.1"
}, },
"devDependencies": { "devDependencies": {
"@zeit/ncc": "^0.20.5" "@vercel/ncc": "^0.28.6",
"eslint": "^7.27.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.3"
}, },
"scripts": { "scripts": {
"build": "ncc build ./src/index.js -o dist" "build": "npm run lint && ncc build ./src/index.js -o dist -m",
"lint": "eslint ./src/index.js",
"lint:fix": "eslint ./src/index.js --fix"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -24,7 +35,7 @@
"rsync" "rsync"
], ],
"author": "Dragan Filipovic", "author": "Dragan Filipovic",
"license": "ISC", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/easingthemes/ssh-deploy/issues" "url": "https://github.com/easingthemes/ssh-deploy/issues"
}, },

38
src/helpers.js Normal file
View File

@@ -0,0 +1,38 @@
const { existsSync, mkdirSync, writeFileSync } = require('fs');
const {
GITHUB_WORKSPACE
} = process.env;
const validateDir = (dir) => {
if (!existsSync(dir)) {
console.log(`[SSH] Creating ${dir} dir in `, GITHUB_WORKSPACE);
mkdirSync(dir);
console.log('✅ [SSH] dir created.');
} else {
console.log(`[SSH] ${dir} dir exist`);
}
};
const validateFile = (filePath) => {
if (!existsSync(filePath)) {
console.log(`[SSH] Creating ${filePath} file in `, GITHUB_WORKSPACE);
try {
writeFileSync(filePath, '', {
encoding: 'utf8',
mode: 0o600
});
console.log('✅ [SSH] file created.');
} catch (e) {
console.error('⚠️ [SSH] writeFileSync error', filePath, e.message);
process.abort();
}
} else {
console.log(`[SSH] ${filePath} file exist`);
}
};
module.exports = {
validateDir,
validateFile
};

View File

@@ -1,153 +1,77 @@
#!/usr/bin/env node #!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const commandExists = require('command-exists');
const nodeCmd = require('node-cmd');
const nodeRsync = require('rsyncwrapper'); const nodeRsync = require('rsyncwrapper');
const { REMOTE_HOST, REMOTE_USER, REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME, SOURCE, TARGET, ARGS, GITHUB_WORKSPACE, HOME } = process.env; const { validateRsync, validateInputs } = require('./rsyncCli');
console.log('GITHUB_WORKSPACE', GITHUB_WORKSPACE); const { addSshKey } = require('./sshKey');
const {
REMOTE_HOST, REMOTE_USER,
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS, EXCLUDE,
GITHUB_WORKSPACE
} = require('./inputs');
const defaultOptions = {
ssh: true,
sshCmdArgs: ['-o StrictHostKeyChecking=no'],
recursive: true
};
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
const sshDeploy = (() => { const sshDeploy = (() => {
const rsync = ({ privateKey, port, src, dest, args }) => { const rsync = ({ privateKey, port, src, dest, args, exclude }) => {
console.log(`Starting Rsync Action: ${src} to ${dest}`); console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
try { try {
// RSYNC COMMAND // RSYNC COMMAND
nodeRsync({ src, dest, args, privateKey, ssh: true, port, sshCmdArgs: ['-o StrictHostKeyChecking=no'], recursive: true }, (error, stdout, stderr, cmd) => { nodeRsync({
src, dest, args, privateKey, port, excludeFirst: exclude, ...defaultOptions
}, (error, stdout, stderr, cmd) => {
if (error) { if (error) {
console.error('⚠️ Rsync error', error.message); console.error('⚠️ [Rsync] error: ', error.message);
console.log('⚠️ [Rsync] stderr: ', stderr);
console.log('⚠️ [Rsync] stdout: ', stdout);
console.log('⚠️ [Rsync] cmd: ', cmd);
process.abort(); process.abort();
} else { } else {
console.log("✅ Rsync finished.", stdout); console.log('[Rsync] finished.', stdout);
} }
}); });
} catch (err) { } catch (err) {
console.error(`⚠️ An error happened:(.`, err.message, err.stack); console.error('⚠️ [Rsync] command error: ', err.message, err.stack);
process.abort(); process.abort();
} }
}; };
const init = ({ const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent, exclude = [] }) => {
src,
dest,
args,
host = 'localhost',
username,
privateKeyContent,
port
}) => {
validateRsync(() => { validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key'); const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
const remoteDest = `${username}@${host}:${dest}`;
const remoteDest = username + '@' + host + ':' + dest; rsync({ privateKey, port, src, dest: remoteDest, args, exclude });
rsync({ privateKey, port, src, dest: remoteDest, args });
}); });
}; };
const validateDir = (dir) => {
if (!fs.existsSync(dir)){
console.log(`Creating ${dir} dir in `, GITHUB_WORKSPACE);
fs.mkdirSync(dir);
} else {
console.log(`${dir} dir exist`);
}
};
const validateFile = (filePath) => {
if (!fs.existsSync(filePath)){
console.log(`Creating ${filePath} file in `, GITHUB_WORKSPACE);
try {
fs.writeFileSync(filePath, '', {
encoding: 'utf8',
mode: 0o600
});
} catch (e) {
console.error('⚠️ writeFileSync error', filePath, e.message);
process.abort();
}
} else {
console.log(`${filePath} file exist`);
}
};
const addSshKey = (key, name) => {
const sshDir = path.join(HOME || __dirname, '.ssh');
const filePath = path.join(sshDir, name);
validateDir(sshDir);
validateFile(sshDir + '/known_hosts');
try {
fs.writeFileSync(filePath, key, {
encoding: 'utf8',
mode: 0o600
});
} catch (e) {
console.error('⚠️ writeFileSync error', filePath, e.message);
process.abort();
}
console.log('✅ Ssh key added to `.ssh` dir ', filePath);
return filePath;
};
const validateRsync = (callback = () => {}) => {
const rsyncCli = commandExists.sync('rsync');
if (!rsyncCli) {
nodeCmd.get(
'sudo apt-get --no-install-recommends install rsync',
function(err, data, stderr){
if (err) {
console.log('⚠️ Rsync installation failed ', err.message);
process.abort();
} else {
console.log('✅ Rsync installed. \n', data, stderr);
callback();
}
}
);
} else {
callback();
}
};
return { return {
init init
} };
})(); })();
const validateInputs = (inputs) => {
const validInputs = inputs.filter(input => {
if (!input) {
console.error(`⚠️ ${input} is mandatory`);
}
return input;
});
if (validInputs.length !== inputs.length) {
process.abort();
}
};
const run = () => { const run = () => {
validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER });
sshDeploy.init({ sshDeploy.init({
src: GITHUB_WORKSPACE + '/' + SOURCE || '', src: `${GITHUB_WORKSPACE}/${SOURCE || ''}`,
dest: TARGET || '/home/' + REMOTE_USER + '/', dest: TARGET || `/home/${REMOTE_USER}/`,
args: [ARGS] || ['-rltgoDzvO'], args: ARGS ? [ARGS] : ['-rltgoDzvO'],
host: REMOTE_HOST, host: REMOTE_HOST,
port: REMOTE_PORT || '22', port: REMOTE_PORT || '22',
username: REMOTE_USER, username: REMOTE_USER,
privateKeyContent: SSH_PRIVATE_KEY, privateKeyContent: SSH_PRIVATE_KEY,
exclude: (EXCLUDE || '').split(',').map((item) => item.trim()) // split by comma and trim whitespace
}); });
}; };
run(); run();

11
src/inputs.js Normal file
View File

@@ -0,0 +1,11 @@
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS', 'EXCLUDE'];
const inputs = {
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
};
// Get inputs from ENV or WITH workflow settings
inputNames.forEach((input) => {
inputs[input] = process.env[input] || process.env[`INPUT_${input}`];
});
module.exports = inputs;

46
src/rsyncCli.js Normal file
View File

@@ -0,0 +1,46 @@
const { sync: commandExists } = require('command-exists');
const { get: nodeCmd } = require('node-cmd');
const validateRsync = (callback = () => {}) => {
const rsyncCli = commandExists('rsync');
if (!rsyncCli) {
nodeCmd(
'sudo apt-get --no-install-recommends install rsync',
(err, data, stderr) => {
if (err) {
console.log('⚠️ [CLI] Rsync installation failed. Aborting ... ', err.message);
process.abort();
} else {
console.log('✅ [CLI] Rsync installed. \n', data, stderr);
callback();
}
}
);
} else {
callback();
}
};
const validateInputs = (inputs) => {
const inputKeys = Object.keys(inputs);
const validInputs = inputKeys.filter((inputKey) => {
const inputValue = inputs[inputKey];
if (!inputValue) {
console.error(`⚠️ [INPUTS] ${inputKey} is mandatory`);
}
return inputValue;
});
if (validInputs.length !== inputKeys.length) {
console.error('⚠️ [INPUTS] Inputs not valid, aborting ...');
process.abort();
}
};
module.exports = {
validateRsync,
validateInputs
};

37
src/sshKey.js Normal file
View File

@@ -0,0 +1,37 @@
const { writeFileSync } = require('fs');
const { join } = require('path');
const {
validateDir,
validateFile
} = require('./helpers');
const {
HOME
} = process.env;
const addSshKey = (key, name) => {
const sshDir = join(HOME || __dirname, '.ssh');
const filePath = join(sshDir, name);
validateDir(sshDir);
validateFile(`${sshDir}/known_hosts`);
try {
writeFileSync(filePath, key, {
encoding: 'utf8',
mode: 0o600
});
} catch (e) {
console.error('⚠️ writeFileSync error', filePath, e.message);
process.abort();
}
console.log('✅ Ssh key added to `.ssh` dir ', filePath);
return filePath;
};
module.exports = {
addSshKey
}