mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2024-11-19 08:08:05 +08:00
Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5d811fd34f | ||
|
40f855a08b | ||
|
45bf266280 | ||
|
650beff82c | ||
|
b6ac6f5c98 | ||
|
58395110fa | ||
|
34a75bf467 | ||
|
dd4fa994f1 | ||
|
fe5dbcff69 | ||
|
148d625f1d | ||
|
c685549dfc | ||
|
4eea1db3aa | ||
|
caa0281bf4 | ||
|
2121ba96bc | ||
|
b65c6688d1 | ||
|
3e2f0214fc | ||
|
45eb75d449 | ||
|
4b6681d89c | ||
|
70415f9f9d | ||
|
5403dab9a0 | ||
|
11f58724d7 | ||
|
5404854e81 | ||
|
4efe6b6c40 | ||
|
a52870b487 | ||
|
d85914e1f9 | ||
|
152ee9d6b2 | ||
|
aeee708bee | ||
|
fd8e654d7e | ||
|
0f6376161f | ||
|
4d8753359e | ||
|
f67f2211cb | ||
|
e577b525ca | ||
|
a3ddddcc15 | ||
|
68642e11e3 | ||
|
2f8e6000d2 | ||
|
8073f2b34c | ||
|
25ffb03f81 | ||
|
6662bf770e | ||
|
c7bd38757d | ||
|
692d3fee7d | ||
|
f7c067b07e | ||
|
d334a45df7 | ||
|
a3412294d1 | ||
|
a9382b67a2 | ||
|
2fdbdb60e6 | ||
|
416e17545e | ||
|
5f8d616f95 | ||
|
cc49ab6239 | ||
|
b1a31cce80 | ||
|
8e3acd84f2 | ||
|
f2f261e6bd | ||
|
80a7f53ec9 | ||
|
d4d82006e8 | ||
|
2de13b41b4 | ||
|
2f40dde84f | ||
|
76660a8456 | ||
|
12adb9b839 | ||
|
c711f2c339 | ||
|
824072bc5a | ||
|
3c36af7577 | ||
|
649339f4bb | ||
|
66e6843055 | ||
|
0867b12954 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
node-version: [14.x]
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
66
.github/workflows/e2e.yml
vendored
Normal file
66
.github/workflows/e2e.yml
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
name: e2e Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 'main' ]
|
||||
|
||||
env:
|
||||
TEST_HOST_DOCKER: ./test
|
||||
TEST_USER: test
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Clean up old test files
|
||||
run: |
|
||||
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
||||
|
||||
- name: Create ssh keys
|
||||
run: |
|
||||
echo $HOME
|
||||
ls -la $HOME
|
||||
ssh-keygen -m PEM -t rsa -b 4096 -f "$HOME/.ssh/id_rsa" -N ""
|
||||
eval `ssh-agent -s`
|
||||
ssh-add "$HOME/.ssh/id_rsa"
|
||||
ssh-add -l
|
||||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_ENV
|
||||
cat $HOME/.ssh/id_rsa >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
|
||||
- name: Build Host Server Image
|
||||
working-directory: ${{ env.TEST_HOST_DOCKER }}
|
||||
run: |
|
||||
docker build \
|
||||
-t ssh-host-image . \
|
||||
--build-arg SSH_PUB_KEY="$(cat $HOME/.ssh/id_rsa.pub)" \
|
||||
--build-arg ssh_user="${{ env.TEST_USER }}"
|
||||
docker run -d -p 8822:22 --name=ssh-host-container ssh-host-image
|
||||
docker exec ssh-host-container sh -c "hostname --ip-address" > ip.txt
|
||||
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
|
||||
cat ip.txt >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Create project file
|
||||
run: |
|
||||
mkdir test_project
|
||||
cd test_project
|
||||
touch index.html
|
||||
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
||||
cat index.html
|
||||
|
||||
- name: e2e Test published ssh-deploy action
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
|
||||
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST1
|
||||
REMOTE_USER: ${{ env.TEST_USER }}
|
||||
ARGS: "-rltgoDzvO"
|
||||
SOURCE: "test_project/"
|
||||
TARGET: "/var/www/html/"
|
||||
EXCLUDE: "/dist/, /node_modules/"
|
2
.github/workflows/manual-release.yml
vendored
2
.github/workflows/manual-release.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-latest ]
|
||||
node-version: [ 14.x ]
|
||||
node-version: [ 16.x ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
10
.github/workflows/release.yml
vendored
10
.github/workflows/release.yml
vendored
@@ -12,13 +12,13 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ ubuntu-latest ]
|
||||
node-version: [ 14.x ]
|
||||
node-version: [ 16.x ]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix['node-version'] }}
|
||||
- name: Install dependencies
|
||||
@@ -28,11 +28,11 @@ jobs:
|
||||
- name: Run Tests
|
||||
run: npm test --if-present
|
||||
- name: Release
|
||||
uses: cycjimmy/semantic-release-action@v2
|
||||
uses: cycjimmy/semantic-release-action@v3
|
||||
with:
|
||||
dry_run: false
|
||||
extra_plugins: |
|
||||
@semantic-release/changelog@3.0.0
|
||||
@semantic-release/changelog
|
||||
@semantic-release/git
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -19,3 +19,4 @@ node_modules/
|
||||
|
||||
# IDE
|
||||
.idea
|
||||
.vscode
|
||||
|
@@ -9,11 +9,13 @@
|
||||
"changelogFile": "docs/CHANGELOG.md"
|
||||
}
|
||||
],
|
||||
"@semantic-release/npm",
|
||||
["@semantic-release/npm", {
|
||||
"npmPublish": false
|
||||
}],
|
||||
[
|
||||
"@semantic-release/git",
|
||||
{
|
||||
"assets": ["docs/CHANGELOG.md"]
|
||||
"assets": ["docs/CHANGELOG.md", "package.json"]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
13
README.md
13
README.md
@@ -62,7 +62,7 @@ or use the latest version from a branch, eg: ssh-deploy@main
|
||||
- name: Deploy to Staging server
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
ARGS: "-rltgoDzvO"
|
||||
SOURCE: "dist/"
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
- name: Deploy to Server
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
ARGS: "-rltgoDzvO --delete"
|
||||
SOURCE: "dist/"
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
@@ -105,6 +105,15 @@ jobs:
|
||||
EXCLUDE: "/dist/, /node_modules/"
|
||||
```
|
||||
|
||||
## Issues
|
||||
|
||||
Almost 95% of the issues are related to wrong SSH connection.
|
||||
I've added e2e test for this action.
|
||||
Check actions tab for example.
|
||||
|
||||
Check manually your ssh connection from your client before opening a bug report.
|
||||
Thanks.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
Check your keys. Check your deployment paths. And use at your own risk.
|
||||
|
@@ -35,7 +35,7 @@ outputs:
|
||||
status:
|
||||
description: "Status"
|
||||
runs:
|
||||
using: "node12"
|
||||
using: "node16"
|
||||
main: "dist/index.js"
|
||||
branding:
|
||||
color: "green"
|
||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,3 +1,46 @@
|
||||
# [3.1.0](https://github.com/easingthemes/ssh-deploy/compare/v3.0.1...v3.1.0) (2022-12-31)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add e2e tests ([40f855a](https://github.com/easingthemes/ssh-deploy/commit/40f855a08b4911c3f54b7a45306af355c6d87277))
|
||||
|
||||
## [3.0.1](https://github.com/easingthemes/ssh-deploy/compare/v3.0.0...v3.0.1) (2022-10-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* readme update ([80a7f53](https://github.com/easingthemes/ssh-deploy/commit/80a7f53ec918930fd23f0524fec0b1d4f52183bf)), closes [#67](https://github.com/easingthemes/ssh-deploy/issues/67)
|
||||
|
||||
# [3.0.0](https://github.com/easingthemes/ssh-deploy/compare/v2.2.11...v3.0.0) (2022-10-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* plugins versions ([2f40dde](https://github.com/easingthemes/ssh-deploy/commit/2f40dde84fde36f5b9b81ededd7090c5159d9885))
|
||||
|
||||
|
||||
* Merge pull request #83 from easingthemes/feature/#82-update-node-version ([76660a8](https://github.com/easingthemes/ssh-deploy/commit/76660a8456dbf26e6328674e25d083941ddd645e)), closes [#83](https://github.com/easingthemes/ssh-deploy/issues/83) [easingthemes/feature/#82](https://github.com/easingthemes/feature//issues/82)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* update to use nodeJS v16
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
|
3329
package-lock.json
generated
3329
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "2.1.9",
|
||||
"version": "3.1.0",
|
||||
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
@@ -9,21 +9,6 @@
|
||||
"./README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"private": false,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"command-exists": "1.2.9",
|
||||
"node-cmd": "4.0.0",
|
||||
"rsyncwrapper": "3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.28.6",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.23.3"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run lint && ncc build ./src/index.js -o dist -m",
|
||||
"lint": "eslint ./src/index.js",
|
||||
@@ -43,5 +28,15 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/easingthemes/ssh-deploy/issues"
|
||||
},
|
||||
"homepage": "https://github.com/easingthemes/ssh-deploy#readme"
|
||||
"homepage": "https://github.com/easingthemes/ssh-deploy#readme",
|
||||
"dependencies": {
|
||||
"command-exists": "^1.2.9",
|
||||
"rsyncwrapper": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vercel/ncc": "^0.36.0",
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-plugin-import": "^2.26.0"
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,9 @@ const defaultOptions = {
|
||||
recursive: true
|
||||
};
|
||||
|
||||
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
|
||||
console.log('GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
|
||||
console.log('REMOTE_HOST: ', process.env.REMOTE_HOST);
|
||||
console.log('REMOTE_USER: ', process.env.REMOTE_USER);
|
||||
|
||||
const sshDeploy = (() => {
|
||||
const rsync = ({ privateKey, port, src, dest, args, exclude }) => {
|
||||
|
@@ -3,7 +3,7 @@ const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KE
|
||||
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}`];
|
||||
});
|
||||
|
@@ -1,25 +1,25 @@
|
||||
const { sync: commandExists } = require('command-exists');
|
||||
const { get: nodeCmd } = require('node-cmd');
|
||||
const { sync: commandExists } = require("command-exists");
|
||||
const { exec, execSync } = require("child_process");
|
||||
|
||||
const validateRsync = (callback = () => {}) => {
|
||||
const rsyncCli = commandExists('rsync');
|
||||
const rsyncCli = commandExists("rsync");
|
||||
if (rsyncCli) {
|
||||
console.log('⚠️ [CLI] Rsync exists');
|
||||
const rsyncVersion = execSync("rsync --version", { stdio: 'inherit' });
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (!rsyncCli) {
|
||||
nodeCmd(
|
||||
'sudo apt-get --no-install-recommends install rsync',
|
||||
(err, data, stderr) => {
|
||||
console.log('⚠️ [CLI] Rsync doesn\'t exists. Start installation with "apt-get" \n');
|
||||
|
||||
exec("sudo apt-get update && sudo apt-get --no-install-recommends install rsync", (err, data, stderr) => {
|
||||
if (err) {
|
||||
console.log('⚠️ [CLI] Rsync installation failed. Aborting ... ', err.message);
|
||||
console.log("⚠️ [CLI] Rsync installation failed. Aborting ... ", err.message);
|
||||
process.abort();
|
||||
} else {
|
||||
console.log('✅ [CLI] Rsync installed. \n', data, stderr);
|
||||
callback();
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
console.log("✅ [CLI] Rsync installed. \n", data, stderr);
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const validateInputs = (inputs) => {
|
||||
@@ -35,12 +35,12 @@ const validateInputs = (inputs) => {
|
||||
});
|
||||
|
||||
if (validInputs.length !== inputKeys.length) {
|
||||
console.error('⚠️ [INPUTS] Inputs not valid, aborting ...');
|
||||
console.error("⚠️ [INPUTS] Inputs not valid, aborting ...");
|
||||
process.abort();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
validateRsync,
|
||||
validateInputs
|
||||
validateInputs,
|
||||
};
|
||||
|
13
src/test.js
Normal file
13
src/test.js
Normal file
@@ -0,0 +1,13 @@
|
||||
console.log('||||||||||||||||||||||||||||||||||||||');
|
||||
console.log('EXAMPLE_REMOTE_HOST: ', process.env.EXAMPLE_REMOTE_HOST);
|
||||
console.log('EXAMPLE_REMOTE_USER: ', process.env.EXAMPLE_REMOTE_USER);
|
||||
console.log('EXAMPLE_SSH_PRIVATE_KEY: ', process.env.EXAMPLE_SSH_PRIVATE_KEY);
|
||||
console.log('||||||||||||||||||||||||||||||||||||||');
|
||||
console.log('EXAMPLE_REMOTE_HOST1: ', process.env.EXAMPLE_REMOTE_HOST1);
|
||||
console.log('EXAMPLE_REMOTE_USER1: ', process.env.EXAMPLE_REMOTE_USER1);
|
||||
console.log('EXAMPLE_SSH_PRIVATE_KEY1: ', process.env.EXAMPLE_SSH_PRIVATE_KEY1);
|
||||
console.log('||||||||||||||||||||||||||||||||||||||');
|
||||
console.log('REMOTE_USER: ', process.env.REMOTE_USER);
|
||||
console.log('REMOTE_HOST: ', process.env.REMOTE_HOST);
|
||||
console.log('SSH_PRIVATE_KEY: ', process.env.SSH_PRIVATE_KEY);
|
||||
console.log('||||||||||||||||||||||||||||||||||||||');
|
5
test/.dockerignore
Normal file
5
test/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
||||
/node_modules
|
||||
.gitignore
|
||||
.gitattributes
|
||||
LICENSE
|
||||
README.md
|
33
test/Dockerfile
Normal file
33
test/Dockerfile
Normal file
@@ -0,0 +1,33 @@
|
||||
FROM nginx
|
||||
|
||||
ARG SSH_PUB_KEY
|
||||
|
||||
RUN apt update
|
||||
|
||||
RUN apt install openssh-server rsync sudo -y
|
||||
|
||||
RUN useradd -rm -d /home/test -s /bin/bash -g root -G sudo -u 1000 test
|
||||
|
||||
RUN usermod -aG sudo test
|
||||
|
||||
RUN echo "PubkeyAuthentication yes" >> /etc/ssh/sshd_config.d/pub.conf
|
||||
RUN echo "AuthorizedKeysFile .ssh/authorized_keys" >> /etc/ssh/sshd_config.d/pub.conf
|
||||
|
||||
RUN mkdir -p /var/www/html
|
||||
RUN chown -R test /var/www/html
|
||||
RUN mkdir -p /home/test/.ssh
|
||||
RUN echo "$SSH_PUB_KEY" > /home/test/.ssh/authorized_keys
|
||||
RUN chmod 700 /home/test/.ssh
|
||||
RUN chown -R test /home/test/.ssh
|
||||
|
||||
RUN service ssh start
|
||||
|
||||
RUN echo 'test:test' | chpasswd
|
||||
|
||||
EXPOSE 22
|
||||
|
||||
ADD entrypoint.sh /docker-entrypoint.d/entrypoint.sh
|
||||
RUN chmod +x /docker-entrypoint.d/entrypoint.sh
|
||||
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
3
test/entrypoint.sh
Normal file
3
test/entrypoint.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/sbin/sshd -D
|
Reference in New Issue
Block a user