mirror of
https://gitee.com/jiulinxiri/ssh-scp-deploy.git
synced 2026-03-10 12:22:55 +08:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3898ca4aab | ||
|
|
9a8b4bdad5 | ||
|
|
a6d3c9af27 | ||
|
|
5557c731df | ||
|
|
acf9c1fefc | ||
|
|
23d4c34561 | ||
|
|
ab06ee730f | ||
|
|
fc430f0194 | ||
|
|
afa413dc37 | ||
|
|
b7443178f2 | ||
|
|
96257c43a1 | ||
|
|
9433396123 | ||
|
|
829467f2f1 | ||
|
|
d4ff23a4b2 | ||
|
|
1b7bbc195c | ||
|
|
c4514ca69d | ||
|
|
6df7204981 | ||
|
|
0f1704d1ab | ||
|
|
bfa5c669b4 | ||
|
|
eee13f37dc | ||
|
|
546131ac6d | ||
|
|
cb11e978e7 | ||
|
|
988984a4c2 | ||
|
|
c842ff43ea | ||
|
|
3631d6aa3e | ||
|
|
c04eabd1e8 | ||
|
|
8f67304c1b | ||
|
|
11b60a4342 | ||
|
|
e700c123e8 | ||
|
|
f254055d37 | ||
|
|
62e6e5e80a | ||
|
|
858fc481b1 | ||
|
|
642835df3d | ||
|
|
8823857dea | ||
|
|
00d3f20007 | ||
|
|
d2658b1812 | ||
|
|
49294a1b9a | ||
|
|
601a3cdfc5 | ||
|
|
874eec1e4c | ||
|
|
21d9038bb4 | ||
|
|
8399b8ccf9 | ||
|
|
4856a9a4e9 | ||
|
|
7d22a8aeeb |
20
.github/workflows/main.yml
vendored
20
.github/workflows/main.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
test:
|
||||
test-key:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -14,10 +14,26 @@ jobs:
|
||||
|
||||
- uses: marcodallasanta/ssh-scp-deploy@main
|
||||
with:
|
||||
local: "CHANGELOG.md"
|
||||
local: "LICENSE"
|
||||
remote: "~/"
|
||||
host: ${{secrets.HOST}}
|
||||
user: ${{secrets.USER}}
|
||||
key: ${{secrets.KEY}}
|
||||
pre_upload: echo "pre_upload 👈"
|
||||
post_upload: echo "post_upload 👉"
|
||||
|
||||
test-pass:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- uses: marcodallasanta/ssh-scp-deploy@development
|
||||
with:
|
||||
local: "CHANGELOG.md"
|
||||
remote: "~/"
|
||||
host: ${{secrets.HOST}}
|
||||
user: ${{secrets.USER}}
|
||||
password: ${{secrets.PASSWORD}}
|
||||
pre_upload: echo "pre_upload 👈"
|
||||
post_upload: echo "post_upload 👉"
|
||||
33
CHANGELOG.md
33
CHANGELOG.md
@@ -1,5 +1,29 @@
|
||||
# [Unreleased]
|
||||
|
||||
## [v1.2.0] - 2021-03-22
|
||||
|
||||
### Added
|
||||
- [Issue #17](https://github.com/marcodallasanta/ssh-scp-deploy/issues/15) - Using /bin/sh instead of /bin/bash.
|
||||
|
||||
## [v1.1.0] - 2021-10-02
|
||||
|
||||
### Added
|
||||
- [Issue #15](https://github.com/marcodallasanta/ssh-scp-deploy/issues/15) - Added -p {INPUT_PORT} option.
|
||||
|
||||
## [v1.0.5] - 2021-09-08
|
||||
|
||||
### Fixed
|
||||
- [Issue #12](https://github.com/marcodallasanta/ssh-scp-deploy/issues/12) - Action never failed also when file/dir was not uploaded.
|
||||
|
||||
## [v1.0.4] - 2021-02-10
|
||||
|
||||
### Fixed
|
||||
- [Issue #9](https://github.com/marcodallasanta/ssh-scp-deploy/issues/9) - Wrong if on password.
|
||||
|
||||
## [v1.0.3] - 2021-02-08
|
||||
|
||||
### Fixed
|
||||
- Hardcoded user "ubuntu" in scp.
|
||||
|
||||
## [v1.0.2] - 2020-12-21
|
||||
|
||||
@@ -18,5 +42,10 @@
|
||||
|
||||
|
||||
[unreleased]: https://github.com/marcodallasanta/ssh-scp-deploy/compare/main...development
|
||||
[v1.0.1]: https://github.com/underscore69/ssh-scp-deploy/tree/v1.0.1
|
||||
[v1.0.0]: https://github.com/underscore69/ssh-scp-deploy/tree/v1.0.0
|
||||
[v1.1.0]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.1.0
|
||||
[v1.0.5]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.0.5
|
||||
[v1.0.4]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.0.4
|
||||
[v1.0.3]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.0.3
|
||||
[v1.0.2]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.0.2
|
||||
[v1.0.1]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.0.1
|
||||
[v1.0.0]: https://github.com/marcodallasanta/ssh-scp-deploy/tree/v1.0.0
|
||||
@@ -3,8 +3,7 @@ FROM alpine:latest
|
||||
RUN apk update && \
|
||||
apk add --no-cache ca-certificates \
|
||||
openssh-client \
|
||||
sshpass \
|
||||
bash
|
||||
sshpass
|
||||
|
||||
COPY LICENSE README.md /
|
||||
COPY entrypoint.sh with_key.sh with_pass.sh /
|
||||
|
||||
28
README.md
28
README.md
@@ -12,7 +12,7 @@
|
||||
|
||||
## ❔ Why should I use this action?
|
||||
|
||||
Because this action provide an easy and higly customizable way to upload files via scp and execute a set of command via ssh before or/and after.
|
||||
Because this action provide an easy and highly customizable way to upload files via scp and execute a set of command via ssh before or/and after.
|
||||
I use this action to deploy my personal projects to remote server, restarting the needed services or to do a simple upload via scp.
|
||||
|
||||
## 🏃 Supported runners
|
||||
@@ -26,7 +26,6 @@ I use this action to deploy my personal projects to remote server, restarting th
|
||||
* Twitter: [@marcodallasanta](https://twitter.com/marcodallasanta)
|
||||
* Github: [@marcodallasanta](https://github.com/marcodallasanta)
|
||||
* LinkedIn: [@marcodallasanta](https://linkedin.com/in/marcodallasanta)
|
||||
* StackOverflow: [@marcodallasanta](https://stackoverflow.com/story/marcodallasanta)
|
||||
|
||||
|
||||
## ⚙️ Usage
|
||||
@@ -34,14 +33,14 @@ I use this action to deploy my personal projects to remote server, restarting th
|
||||
- uses: mdallasanta/ssh-scp-deploy@{version}
|
||||
with:
|
||||
local: './' # Local file path - REQUIRED false - DEFAULT ./
|
||||
remote: '~/' # Remote file path - REQUIRED false - DEFAULT ~/
|
||||
host: ${{secrets.HOST}} # Remote server address - REQUIRED true
|
||||
port: ${{secrets.PORT}} # Remote server port - REQUIRED false - DEFAULT 22
|
||||
remote: '~/' # Remote file path - REQUIRED false - DEFAULT ~/
|
||||
host: ${{secrets.HOST}} # Remote server address - REQUIRED true
|
||||
port: ${{secrets.PORT}} # Remote server port - REQUIRED false - DEFAULT 22
|
||||
user: ${{secrets.USER}} # Remote server user - REQUIRED true
|
||||
password: ${{secrets.PASSWORD}} # User password - REQUIRED at least one of "password" or "key"
|
||||
key: ${{secrets.KEY}} # Remote server private key - REQUIRED at least one of "password" or "key"
|
||||
pre_upload: echo "This will be executed before the upload!" # Command to run via ssh before scp upload - REQUIRED false
|
||||
post_upload: echo "This will be executed after the upload!" # Command to run via ssh after scp upload - REQUIRED false
|
||||
password: ${{secrets.PASSWORD}} # User password - REQUIRED at least one of "password" or "key"
|
||||
key: ${{secrets.KEY}} # Remote server private key - REQUIRED at least one of "password" or "key"
|
||||
pre_upload: echo "This will be executed before the upload!" # Command to run via ssh before scp upload - REQUIRED false
|
||||
post_upload: echo "This will be executed after the upload!" # Command to run via ssh after scp upload - REQUIRED false
|
||||
ssh_options: -o StrictHostKeyChecking=no # A set of ssh_option separated by -o - REQUIRED false - DEFAULT -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null
|
||||
scp_options: -v # Flags to use during scp - REQUIRED false - DEFAULT ''
|
||||
```
|
||||
@@ -54,10 +53,15 @@ Feel free to check [issues page](https://github.com/mdallasanta/ssh-scp-deploy/i
|
||||
|
||||
## 🙏 Thanks
|
||||
|
||||
Thanks to [Raphaël Bussa](https://github.com/raphaelbussa) for help in testing.
|
||||
Thanks to:
|
||||
|
||||
- [Raphaël Bussa](https://github.com/raphaelbussa) for help in testing.
|
||||
- [jamesremuscat](https://github.com/jamesremuscat) for resolving [issue#15](https://github.com/marcodallasanta/ssh-scp-deploy/issues/15)
|
||||
- [Blake Drumm](https://github.com/x-limitless-x) for resolving [issue#19](https://github.com/marcodallasanta/ssh-scp-deploy/issues/19)
|
||||
|
||||
|
||||
## 📝 License
|
||||
|
||||
Copyright © 2020 [Marco Dalla Santa](https://github.com/marcoallasanta)
|
||||
Copyright © 2020-2022 [Marco Dalla Santa](https://github.com/marcodallasanta)
|
||||
|
||||
The source code, scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
The source code, scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
PASSWORD=${INPUT_PASSWORD};
|
||||
KEY=${INPUT_KEY};
|
||||
|
||||
if [ -z "$PRE_UPLOAD" ] && [ "$PASSWORD" ]; then
|
||||
if [ -z "$KEY" ] && [ -z "$PASSWORD" ]; then
|
||||
echo "🔑 Please provide at least a key or a password...";
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
32
with_key.sh
32
with_key.sh
@@ -1,3 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "🔑 Adding ssh key..." &&
|
||||
eval $(ssh-agent -s) &&
|
||||
ssh-add <(echo "${INPUT_KEY}") &&
|
||||
@@ -5,20 +7,32 @@ echo "🔐 Added ssh key";
|
||||
|
||||
PRE_UPLOAD=${INPUT_PRE_UPLOAD}
|
||||
if [ ! -z "$PRE_UPLOAD" ]; then
|
||||
echo "👌 Executing pre-upload script..." &&
|
||||
ssh ${INPUT_SSH_OPTIONS} ${INPUT_USER}@${INPUT_HOST} "$INPUT_PRE_UPLOAD && exit" &&
|
||||
echo "✅ Executed pre-upload script";
|
||||
{
|
||||
echo "👌 Executing pre-upload script..." &&
|
||||
ssh ${INPUT_SSH_OPTIONS} -p "${INPUT_PORT}" ${INPUT_USER}@${INPUT_HOST} "$INPUT_PRE_UPLOAD && exit" &&
|
||||
echo "✅ Executed pre-upload script"
|
||||
} || {
|
||||
echo "😢 Something went wrong during pre-upload script" && exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "🚚 Uploading via scp..." &&
|
||||
scp ${INPUT_SSH_OPTIONS} ${INPUT_SCP_OPTIONS} -P "${INPUT_PORT}" -r ${INPUT_LOCAL} ubuntu@${INPUT_HOST}:"${INPUT_REMOTE}" &&
|
||||
echo "🙌 Uploaded via scp";
|
||||
{
|
||||
echo "🚚 Uploading via scp..." &&
|
||||
scp ${INPUT_SSH_OPTIONS} ${INPUT_SCP_OPTIONS} -P "${INPUT_PORT}" -r ${INPUT_LOCAL} ${INPUT_USER}@${INPUT_HOST}:"${INPUT_REMOTE}" &&
|
||||
echo "🙌 Uploaded via scp"
|
||||
} || {
|
||||
echo "😢 Something went wrong during upload" && exit 1
|
||||
}
|
||||
|
||||
POST_UPLOAD=${INPUT_POST_UPLOAD}
|
||||
if [ ! -z "$POST_UPLOAD" ]; then
|
||||
echo "👌 Executing post-upload script..." &&
|
||||
ssh ${INPUT_SSH_OPTIONS} ${INPUT_USER}@${INPUT_HOST} "$POST_UPLOAD && exit" &&
|
||||
echo "✅ Executed post-upload script";
|
||||
{
|
||||
echo "👌 Executing post-upload script..." &&
|
||||
ssh ${INPUT_SSH_OPTIONS} -p "${INPUT_PORT}" ${INPUT_USER}@${INPUT_HOST} "$POST_UPLOAD && exit" &&
|
||||
echo "✅ Executed post-upload script"
|
||||
} || {
|
||||
echo "😢 Something went wrong during post-upload script" && exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "🎉 Done";
|
||||
32
with_pass.sh
32
with_pass.sh
@@ -1,19 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
PRE_UPLOAD=${INPUT_PRE_UPLOAD}
|
||||
if [ ! -z "$PRE_UPLOAD" ]; then
|
||||
echo "👌 Executing pre-upload script..." &&
|
||||
sshpass -p ${PASSWORD} ssh ${INPUT_SSH_OPTIONS} ${INPUT_USER}@${INPUT_HOST} "$INPUT_PRE_UPLOAD && exit" &&
|
||||
echo "✅ Executed pre-upload script";
|
||||
{
|
||||
echo "👌 Executing pre-upload script..." &&
|
||||
sshpass -p ${PASSWORD} ssh ${INPUT_SSH_OPTIONS} -p "${INPUT_PORT}" ${INPUT_USER}@${INPUT_HOST} "$INPUT_PRE_UPLOAD && exit" &&
|
||||
echo "✅ Executed pre-upload script"
|
||||
} || {
|
||||
echo "😢 Something went wrong during pre-upload script" && exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "🚚 Uploading via scp..." &&
|
||||
sshpass -p ${PASSWORD} scp ${INPUT_SSH_OPTIONS} ${INPUT_SCP_OPTIONS} -P "${INPUT_PORT}" -r ${INPUT_LOCAL} ubuntu@${INPUT_HOST}:"${INPUT_REMOTE}" &&
|
||||
echo "🙌 Uploaded via scp";
|
||||
{
|
||||
echo "🚚 Uploading via scp..." &&
|
||||
sshpass -p ${PASSWORD} scp ${INPUT_SSH_OPTIONS} ${INPUT_SCP_OPTIONS} -P "${INPUT_PORT}" -r ${INPUT_LOCAL} ${INPUT_USER}@${INPUT_HOST}:"${INPUT_REMOTE}" &&
|
||||
echo "🙌 Uploaded via scp"
|
||||
} || {
|
||||
echo "😢 Something went wrong during upload" && exit 1
|
||||
}
|
||||
|
||||
POST_UPLOAD=${INPUT_POST_UPLOAD}
|
||||
if [ ! -z "$POST_UPLOAD" ]; then
|
||||
echo "👌 Executing post-upload script..." &&
|
||||
sshpass -p ${PASSWORD} ssh ${INPUT_SSH_OPTIONS} ${INPUT_USER}@${INPUT_HOST} "$POST_UPLOAD && exit" &&
|
||||
echo "✅ Executed post-upload script";
|
||||
{
|
||||
echo "👌 Executing post-upload script..." &&
|
||||
sshpass -p ${PASSWORD} ssh ${INPUT_SSH_OPTIONS} -p "${INPUT_PORT}" ${INPUT_USER}@${INPUT_HOST} "$POST_UPLOAD && exit" &&
|
||||
echo "✅ Executed post-upload script"
|
||||
} || {
|
||||
echo "😢 Something went wrong during post-upload script" && exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
echo "🎉 Done";
|
||||
Reference in New Issue
Block a user