mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2024-11-19 08:08:05 +08:00
Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
79363f2b74 | ||
|
7c21074882 | ||
|
9f191f4263 | ||
|
006cf3021d | ||
|
8be4106fce | ||
|
7c9b40539e | ||
|
2169399fef | ||
|
2be7efb376 | ||
|
e6e41a57ec | ||
|
c8d57ec8b4 | ||
|
8bf58fb293 | ||
|
6d3554b01e | ||
|
8ad0b68b03 | ||
|
765f5ffd31 | ||
|
bd84b4a501 | ||
|
0069faea9f | ||
|
f6dd2006c5 | ||
|
923bc68f1a | ||
|
5c13615d4b | ||
|
73a65ec97c | ||
|
98ee38d52e | ||
|
bfa025c10c | ||
|
a73c81ee7b | ||
|
91b6d280ae | ||
|
4f233a7f45 | ||
|
47f78aa96e | ||
|
8e19e0d6bc | ||
|
da62405174 | ||
|
2a85c96230 | ||
|
ac90bba983 | ||
|
05ddb64347 | ||
|
8f715957ab |
104
.github/workflows/e2e-manual.yml
vendored
Normal file
104
.github/workflows/e2e-manual.yml
vendored
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
name: e2e Manual Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
ARGS:
|
||||||
|
description: 'ARGS'
|
||||||
|
required: true
|
||||||
|
default: '-rlgoDzvc -i --delete --chmod=ugo+rwX --progress'
|
||||||
|
EXCLUDE:
|
||||||
|
description: 'EXCLUDE'
|
||||||
|
required: true
|
||||||
|
default: 'skip_dir/, /node_modules/'
|
||||||
|
SSH_CMD_ARGS:
|
||||||
|
description: 'SSH_CMD_ARGS'
|
||||||
|
required: true
|
||||||
|
default: '-o StrictHostKeyChecking=no, -o UserKnownHostsFile=/dev/null'
|
||||||
|
|
||||||
|
|
||||||
|
env:
|
||||||
|
TEST_HOST_DOCKER: ./test
|
||||||
|
TEST_USER: test
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
e2e-manual:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# START E2E Test Specific - steps
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
- name: E2E Test Specific - Clean up old test files
|
||||||
|
run: |
|
||||||
|
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
||||||
|
|
||||||
|
- name: E2E Test Specific - 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: E2E Test Specific - 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)"
|
||||||
|
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: E2E Test Specific - Create project file
|
||||||
|
run: |
|
||||||
|
mkdir test_project2 && cd "$_"
|
||||||
|
truncate -s 5MB info2.txt
|
||||||
|
cd ../
|
||||||
|
mkdir test_project && cd "$_"
|
||||||
|
touch index.html
|
||||||
|
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
||||||
|
truncate -s 50MB image.svg
|
||||||
|
truncate -s 5MB info.txt
|
||||||
|
truncate -s 500MB big_file.txt
|
||||||
|
mkdir skip_dir && cd "$_"
|
||||||
|
truncate -s 5MB text_in_skip_dir.txt
|
||||||
|
cd ../
|
||||||
|
cat index.html
|
||||||
|
echo "test_project:" && ls -lR
|
||||||
|
echo "skip_dir:" && ls -lR skip_dir
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# END E2E Test Specific - steps
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
- name: e2e Test ssh-deploy action
|
||||||
|
uses: easingthemes/ssh-deploy@main
|
||||||
|
env:
|
||||||
|
# ENV Vars created in previous steps:
|
||||||
|
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
|
||||||
|
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
|
||||||
|
REMOTE_USER: ${{ env.TEST_USER }}
|
||||||
|
ARGS: ${{ github.event.inputs.ARGS }}
|
||||||
|
SSH_CMD_ARGS: ${{ github.event.inputs.SSH_CMD_ARGS }}
|
||||||
|
SOURCE: test_project/ test_project2/
|
||||||
|
TARGET: /var/www/html/
|
||||||
|
EXCLUDE: ${{ github.event.inputs.EXCLUDE }}
|
||||||
|
SCRIPT_BEFORE: |
|
||||||
|
whoami
|
||||||
|
ls -lR /var/www/html/
|
||||||
|
SCRIPT_AFTER: |
|
||||||
|
ls -lR /var/www/html/
|
||||||
|
echo $RSYNC_STDOUT
|
145
.github/workflows/e2e.yml
vendored
145
.github/workflows/e2e.yml
vendored
@@ -7,6 +7,7 @@ on:
|
|||||||
env:
|
env:
|
||||||
TEST_HOST_DOCKER: ./test
|
TEST_HOST_DOCKER: ./test
|
||||||
TEST_USER: test
|
TEST_USER: test
|
||||||
|
TEST_USER2: test2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
e2e:
|
e2e:
|
||||||
@@ -16,11 +17,15 @@ jobs:
|
|||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Clean up old test files
|
# : ---------------------------------------------------------------
|
||||||
|
# : START E2E Test Specific - steps
|
||||||
|
# : ----------------------------------------------------------------
|
||||||
|
|
||||||
|
- name: E2E Test Specific - Clean up old test files
|
||||||
run: |
|
run: |
|
||||||
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
||||||
|
|
||||||
- name: Create ssh keys
|
- name: E2E Test Specific - Create ssh keys
|
||||||
run: |
|
run: |
|
||||||
echo $HOME
|
echo $HOME
|
||||||
ls -la $HOME
|
ls -la $HOME
|
||||||
@@ -32,13 +37,12 @@ jobs:
|
|||||||
cat $HOME/.ssh/id_rsa >> $GITHUB_ENV
|
cat $HOME/.ssh/id_rsa >> $GITHUB_ENV
|
||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Build Host Server Image
|
- name: E2E Test Specific - Build Host Server Image
|
||||||
working-directory: ${{ env.TEST_HOST_DOCKER }}
|
working-directory: ${{ env.TEST_HOST_DOCKER }}
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
-t ssh-host-image . \
|
-t ssh-host-image . \
|
||||||
--build-arg SSH_PUB_KEY="$(cat $HOME/.ssh/id_rsa.pub)" \
|
--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 run -d -p 8822:22 --name=ssh-host-container ssh-host-image
|
||||||
docker exec ssh-host-container sh -c "hostname --ip-address" > ip.txt
|
docker exec ssh-host-container sh -c "hostname --ip-address" > ip.txt
|
||||||
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
|
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
|
||||||
@@ -46,29 +50,124 @@ jobs:
|
|||||||
echo "EOF" >> $GITHUB_ENV
|
echo "EOF" >> $GITHUB_ENV
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Create project file
|
- name: E2E Test Specific - Create project file
|
||||||
run: |
|
run: |
|
||||||
mkdir test_project
|
mkdir test_project2 && cd "$_"
|
||||||
cd test_project
|
truncate -s 5MB info2.txt
|
||||||
|
cd ../
|
||||||
|
mkdir test_project && cd "$_"
|
||||||
touch index.html
|
touch index.html
|
||||||
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
||||||
|
truncate -s 50MB image.svg
|
||||||
|
truncate -s 5MB info.txt
|
||||||
|
truncate -s 500MB big_file.txt
|
||||||
|
mkdir skip_dir && cd "$_"
|
||||||
|
truncate -s 5MB text_in_skip_dir.txt
|
||||||
|
cd ../
|
||||||
cat index.html
|
cat index.html
|
||||||
|
echo "test_project:" && ls -lR
|
||||||
|
echo "skip_dir:" && ls -lR skip_dir
|
||||||
|
|
||||||
- name: e2e Test published ssh-deploy action
|
# ----------------------------------------------------------------
|
||||||
|
# END E2E Test Specific - steps
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
- name: set shared ENV variables for multi target deployment
|
||||||
|
run: |
|
||||||
|
echo "ARGS=-rlgoDzvcR -i --delete --chmod=ugo+rwX --progress" >> $GITHUB_ENV
|
||||||
|
echo "SSH_CMD_ARGS=-o StrictHostKeyChecking=no, -o UserKnownHostsFile=/dev/null" >> $GITHUB_ENV
|
||||||
|
echo "SOURCE=test_project/ test_project2/" >> $GITHUB_ENV
|
||||||
|
echo "EXCLUDE=skip_dir/, /node_modules/" >> $GITHUB_ENV
|
||||||
|
echo "SCRIPT_BEFORE<<EOF" >> $GITHUB_ENV
|
||||||
|
echo "whoami" >> $GITHUB_ENV
|
||||||
|
echo "ls -lR /var/www/html/" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
echo "SCRIPT_AFTER<<EOF" >> $GITHUB_ENV
|
||||||
|
echo $RSYNC_STDOUT >> $GITHUB_ENV
|
||||||
|
echo "ls -lR /var/www/html/" >> $GITHUB_ENV
|
||||||
|
echo "EOF" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: e2e Test ssh-deploy action - Target 1
|
||||||
uses: easingthemes/ssh-deploy@main
|
uses: easingthemes/ssh-deploy@main
|
||||||
env:
|
env:
|
||||||
# ENV Vars created in previous steps:
|
# Shared ENV Vars created in previous steps
|
||||||
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
|
|
||||||
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
|
|
||||||
REMOTE_USER: ${{ env.TEST_USER }}
|
REMOTE_USER: ${{ env.TEST_USER }}
|
||||||
ARGS: "-rltgoDzvO"
|
TARGET: /var/www/html/${{ env.TEST_USER }}
|
||||||
SOURCE: "test_project/"
|
|
||||||
TARGET: "/var/www/html/"
|
- name: e2e Test ssh-deploy action - Target 2
|
||||||
EXCLUDE: "/dist/, /node_modules/"
|
uses: easingthemes/ssh-deploy@main
|
||||||
SCRIPT_BEFORE: |
|
env:
|
||||||
whoami
|
# Shared ENV Vars created in previous steps
|
||||||
ls -al
|
REMOTE_USER: ${{ env.TEST_USER2 }}
|
||||||
SCRIPT_AFTER: |
|
TARGET: /var/www/html/${{ env.TEST_USER2 }}
|
||||||
whoami
|
e2e-v3:
|
||||||
ls -al
|
runs-on: ubuntu-latest
|
||||||
echo $RSYNC_STDOUT
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# : ---------------------------------------------------------------
|
||||||
|
# : START E2E Test Specific - steps
|
||||||
|
# : ----------------------------------------------------------------
|
||||||
|
|
||||||
|
- name: E2E Test Specific - Clean up old test files
|
||||||
|
run: |
|
||||||
|
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
||||||
|
|
||||||
|
- name: E2E Test Specific - 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: E2E Test Specific - 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)"
|
||||||
|
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: E2E Test Specific - Create project file
|
||||||
|
run: |
|
||||||
|
mkdir test_project2 && cd "$_"
|
||||||
|
truncate -s 5MB info2.txt
|
||||||
|
cd ../
|
||||||
|
mkdir test_project && cd "$_"
|
||||||
|
touch index.html
|
||||||
|
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
||||||
|
truncate -s 50MB image.svg
|
||||||
|
truncate -s 5MB info.txt
|
||||||
|
truncate -s 500MB big_file.txt
|
||||||
|
mkdir skip_dir && cd "$_"
|
||||||
|
truncate -s 5MB text_in_skip_dir.txt
|
||||||
|
cd ../
|
||||||
|
cat index.html
|
||||||
|
echo "test_project:" && ls -lR
|
||||||
|
echo "skip_dir:" && ls -lR skip_dir
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
# END E2E Test Specific - steps
|
||||||
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
- name: e2e Test ssh-deploy action - Target 1
|
||||||
|
uses: easingthemes/ssh-deploy@v3.4.3
|
||||||
|
env:
|
||||||
|
# Shared ENV Vars created in previous steps
|
||||||
|
REMOTE_USER: ${{ env.TEST_USER }}
|
||||||
|
TARGET: /var/www/html/${{ env.TEST_USER }}
|
||||||
|
SOURCE: test_project/
|
||||||
|
EXCLUDE: skip_dir/, /node_modules/
|
||||||
|
ARGS: -rlgoDzvcO
|
||||||
|
71
.github/workflows/manual-release.yml
vendored
71
.github/workflows/manual-release.yml
vendored
@@ -2,43 +2,72 @@ name: Manual Release
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
dryrun:
|
version:
|
||||||
description: 'DryRUn'
|
description: 'Version'
|
||||||
|
type: choice
|
||||||
required: true
|
required: true
|
||||||
default: 'false'
|
default: patch
|
||||||
|
options:
|
||||||
|
- patch
|
||||||
|
- minor
|
||||||
|
- major
|
||||||
|
dryRun:
|
||||||
|
description: 'DryRun'
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
# ENV and Config
|
||||||
|
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
|
||||||
|
CONFIG_NODE_VERSION: '["lts/*"]'
|
||||||
|
CONFIG_OS: '["ubuntu-latest"]'
|
||||||
|
# Main Job
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
config:
|
||||||
name: Test, Build and Release
|
runs-on: ubuntu-latest
|
||||||
runs-on: ${{ matrix.os }}
|
outputs:
|
||||||
|
NODE_VERSION: ${{ steps.set-config.outputs.CONFIG_NODE_VERSION }}
|
||||||
|
OS: ${{ steps.set-config.outputs.CONFIG_OS }}
|
||||||
|
steps:
|
||||||
|
- id: set-config
|
||||||
|
run: |
|
||||||
|
echo "CONFIG_NODE_VERSION=${{ toJSON(env.CONFIG_NODE_VERSION) }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "CONFIG_OS=${{ toJSON(env.CONFIG_OS) }}" >> $GITHUB_OUTPUT
|
||||||
|
release-manual:
|
||||||
|
name: Test, Build and force Release
|
||||||
|
needs: config
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.OS }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ ubuntu-latest ]
|
OS: ${{ fromJSON(needs.config.outputs.OS) }}
|
||||||
node-version: [ 16.x ]
|
NODE_VERSION: ${{ fromJSON(needs.config.outputs.NODE_VERSION) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js ${{ matrix.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix['node-version'] }}
|
node-version: ${{ matrix.NODE_VERSION }}
|
||||||
|
- name: Commit trigger
|
||||||
|
run: |
|
||||||
|
git commit --allow-empty -m "${{ github.event.inputs.version }}: Trigger Manual Release"
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Build Library
|
- name: Build Library
|
||||||
run: npm run build --if-present
|
run: npm run build --if-present
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: npm test --if-present
|
run: npm test --if-present
|
||||||
- name: Release
|
- name: Publish npm package
|
||||||
uses: cycjimmy/semantic-release-action@v3
|
uses: cycjimmy/semantic-release-action@v3
|
||||||
with:
|
with:
|
||||||
dry_run: ${{ github.event.inputs.dryrun == 'true' }}
|
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
|
||||||
extra_plugins: |
|
extra_plugins: |
|
||||||
@semantic-release/changelog
|
@semantic-release/changelog
|
||||||
@semantic-release/git
|
@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
|
|
||||||
|
20
README.md
20
README.md
@@ -41,13 +41,14 @@ eg: myusername
|
|||||||
|
|
||||||
eg: '59184'
|
eg: '59184'
|
||||||
|
|
||||||
##### 5. `ARGS` (optional, default '-rltgoDzvO')
|
##### 5. `ARGS` (optional, default '-rlgoDzvc -i')
|
||||||
|
|
||||||
For any initial/required rsync flags, eg: `-avzr --delete`
|
For any initial/required rsync flags, eg: `-avzr --delete`
|
||||||
|
|
||||||
##### 6. `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/`.
|
||||||
|
Multiple sources should be separated by space.
|
||||||
|
|
||||||
##### 7. `TARGET` (optional, default '/home/REMOTE_USER/')
|
##### 7. `TARGET` (optional, default '/home/REMOTE_USER/')
|
||||||
|
|
||||||
@@ -61,6 +62,8 @@ path to exclude separated by `,`, ie: `/dist/, /node_modules/`
|
|||||||
|
|
||||||
Script to run on host machine before rsync. Single line or multiline commands.
|
Script to run on host machine before rsync. Single line or multiline commands.
|
||||||
Execution is preformed by storing commands in `.sh` file and executing it via `.bash` over `ssh`
|
Execution is preformed by storing commands in `.sh` file and executing it via `.bash` over `ssh`
|
||||||
|
If you have issues with `ssh` connection, use this var, eg `SCRIPT_BEFORE: ls`.
|
||||||
|
This will force `known_hosts` update, adding your host via `ssh-keyscan`.
|
||||||
|
|
||||||
##### 10. `SCRIPT_AFTER` (optional, default '')
|
##### 10. `SCRIPT_AFTER` (optional, default '')
|
||||||
|
|
||||||
@@ -82,7 +85,7 @@ or use the latest version from a branch, eg: ssh-deploy@main
|
|||||||
uses: easingthemes/ssh-deploy@main
|
uses: easingthemes/ssh-deploy@main
|
||||||
env:
|
env:
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
ARGS: "-rltgoDzvO"
|
ARGS: "-rlgoDzvc -i"
|
||||||
SOURCE: "dist/"
|
SOURCE: "dist/"
|
||||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||||
@@ -123,7 +126,7 @@ jobs:
|
|||||||
uses: easingthemes/ssh-deploy@main
|
uses: easingthemes/ssh-deploy@main
|
||||||
env:
|
env:
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
ARGS: "-rltgoDzvO --delete"
|
ARGS: "-rlgoDzvc -i --delete"
|
||||||
SOURCE: "dist/"
|
SOURCE: "dist/"
|
||||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||||
@@ -148,6 +151,15 @@ Check actions tab for example.
|
|||||||
|
|
||||||
More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication
|
More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication
|
||||||
|
|
||||||
|
## Tips
|
||||||
|
|
||||||
|
- Optional ENV variables are created for simple requirements.
|
||||||
|
For complex use cases, use `ARGS` and `SSH_CMD_ARGS` to fully configure `rsync` with all possible options.
|
||||||
|
- If you need to use multiple steps, eg multi targets deployment, save shared ENV variables in `>> $GITHUB_ENV`.
|
||||||
|
Check .github/workflows/e2e.yml for an example
|
||||||
|
- For multi sources, use -R ARG to manipulate folders structure.
|
||||||
|
- Great post about `rsync` options specific to usage of this action: https://logansnotes.com/2020/gh-action-site-deploy/
|
||||||
|
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@ inputs:
|
|||||||
ARGS:
|
ARGS:
|
||||||
description: "Arguments to pass to rsync"
|
description: "Arguments to pass to rsync"
|
||||||
required: false
|
required: false
|
||||||
default: "-rltgoDzvO"
|
default: "-rlgoDzvc -i"
|
||||||
SSH_CMD_ARGS:
|
SSH_CMD_ARGS:
|
||||||
description: "An array of ssh arguments, they must be prefixed with -o and separated by a comma, for example: -o SomeArgument=no, -o SomeOtherArgument=5 "
|
description: "An array of ssh arguments, they must be prefixed with -o and separated by a comma, for example: -o SomeArgument=no, -o SomeOtherArgument=5 "
|
||||||
required: false
|
required: false
|
||||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,3 +1,88 @@
|
|||||||
|
## [4.0.1](https://github.com/easingthemes/ssh-deploy/compare/v4.0.0...v4.0.1) (2023-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* fix default source if empty ([9f191f4](https://github.com/easingthemes/ssh-deploy/commit/9f191f42633c4a0f66054f0fc229c9e30a08f00c))
|
||||||
|
|
||||||
|
# [4.0.0](https://github.com/easingthemes/ssh-deploy/compare/v3.4.3...v4.0.0) (2023-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* rebuild ([2169399](https://github.com/easingthemes/ssh-deploy/commit/2169399fef9a60a2fea1ab03cce4ec8c2371e5c2))
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* update default rsync options ([2be7efb](https://github.com/easingthemes/ssh-deploy/commit/2be7efb376866327c1d1209f51eb43f34f07b354))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* Default rsync options updated to speed up default deployments.
|
||||||
|
from `rltgoDzvO` to `-rlgoDzvc -i`
|
||||||
|
|
||||||
|
## [3.4.3](https://github.com/easingthemes/ssh-deploy/compare/v3.4.2...v3.4.3) (2023-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* move e2e tests typo branch name ([6d3554b](https://github.com/easingthemes/ssh-deploy/commit/6d3554b01e9a05de9a9d2b30274bee411a4986ed))
|
||||||
|
|
||||||
|
## [3.4.2](https://github.com/easingthemes/ssh-deploy/compare/v3.4.1...v3.4.2) (2023-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Update changelog ([765f5ff](https://github.com/easingthemes/ssh-deploy/commit/765f5ffd3153c76442521c61c04656cafc182731))
|
||||||
|
|
||||||
|
## [3.4.1](https://github.com/easingthemes/ssh-deploy/compare/v3.4.0...v3.4.1) (2023-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* move e2e tests to main branch ([0069fae](https://github.com/easingthemes/ssh-deploy/commit/0069faea9ff3ea3cdd095b0f2663c9e2bcd97480))
|
||||||
|
|
||||||
|
# [3.4.0](https://github.com/easingthemes/ssh-deploy/compare/v3.3.4...v3.4.0) (2023-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/easingthemes/ssh-deploy/compare/v3.1.0...v3.4.1
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Add SSH remote script support - before and after rsync ([2cd8a82](https://github.com/easingthemes/ssh-deploy/commit/2cd8a820e22135b7002fbe6a47cf33f99e2d337b))
|
||||||
|
* Add multi source and multi target support ([73a65ec](https://github.com/easingthemes/ssh-deploy/commit/73a65ec97c5046a53f6b4c40823be5fd3826ede0))
|
||||||
|
* Add SSH_CMD_ARGS support ([51a0063](https://github.com/easingthemes/ssh-deploy/commit/51a00631e2b91983fb610ca2157a673b9ae03c95))
|
||||||
|
* Add manual inputs for e2e test ([8f71595](https://github.com/easingthemes/ssh-deploy/commit/8f715957ab9283ab2934dd1e5be9d78f2eaf3fae))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Add visible Rsync CMD for debugging ([91b6d28](https://github.com/easingthemes/ssh-deploy/commit/91b6d280aee6a7ae666a11426fb356406f4a25a5))
|
||||||
|
* log buffer from rsync stdout ([8e19e0d](https://github.com/easingthemes/ssh-deploy/commit/8e19e0d6bc9b1c332925ce0268ad64b50728fae5))
|
||||||
|
* fix e2e yaml step name ([5c13615](https://github.com/easingthemes/ssh-deploy/commit/5c13615d4b7b0bda47f622ac5f4444484d8bcdb4))
|
||||||
|
|
||||||
|
## [3.3.4](https://github.com/easingthemes/ssh-deploy/compare/v3.3.3...v3.3.4) (2023-01-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Add visible Rsync CMD for debugging ([91b6d28](https://github.com/easingthemes/ssh-deploy/commit/91b6d280aee6a7ae666a11426fb356406f4a25a5))
|
||||||
|
|
||||||
|
## [3.3.3](https://github.com/easingthemes/ssh-deploy/compare/v3.3.2...v3.3.3) (2023-01-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* log buffer from rsync stdout ([8e19e0d](https://github.com/easingthemes/ssh-deploy/commit/8e19e0d6bc9b1c332925ce0268ad64b50728fae5))
|
||||||
|
|
||||||
|
## [3.3.2](https://github.com/easingthemes/ssh-deploy/compare/v3.3.1...v3.3.2) (2023-01-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Add manual inputs for e2e test ([8f71595](https://github.com/easingthemes/ssh-deploy/commit/8f715957ab9283ab2934dd1e5be9d78f2eaf3fae))
|
||||||
|
|
||||||
## [3.3.1](https://github.com/easingthemes/ssh-deploy/compare/v3.3.0...v3.3.1) (2023-01-02)
|
## [3.3.1](https://github.com/easingthemes/ssh-deploy/compare/v3.3.0...v3.3.1) (2023-01-02)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@draganfilipovic/ssh-deploy",
|
"name": "@draganfilipovic/ssh-deploy",
|
||||||
"version": "3.3.1",
|
"version": "4.0.1",
|
||||||
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to 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": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"files": [
|
"files": [
|
||||||
|
@@ -10,12 +10,12 @@ const githubWorkspace = process.env.GITHUB_WORKSPACE;
|
|||||||
const remoteUser = process.env.REMOTE_USER;
|
const remoteUser = process.env.REMOTE_USER;
|
||||||
|
|
||||||
const defaultInputs = {
|
const defaultInputs = {
|
||||||
source: '',
|
source: './',
|
||||||
target: `/home/${remoteUser}/`,
|
target: `/home/${remoteUser}/`,
|
||||||
exclude: '',
|
exclude: '',
|
||||||
args: '-rltgoDzvO',
|
args: '-rlgoDzvc -i',
|
||||||
sshCmdArgs: '-o StrictHostKeyChecking=no',
|
sshCmdArgs: '-o StrictHostKeyChecking=no',
|
||||||
deployKeyName: 'deploy_key'
|
deployKeyName: `deploy_key_${remoteUser}_${Date.now()}`
|
||||||
};
|
};
|
||||||
|
|
||||||
const inputs = {
|
const inputs = {
|
||||||
@@ -30,10 +30,12 @@ inputNames.forEach((input) => {
|
|||||||
// eslint-disable-next-line default-case
|
// eslint-disable-next-line default-case
|
||||||
switch (inputName) {
|
switch (inputName) {
|
||||||
case 'source':
|
case 'source':
|
||||||
extendedVal = `${githubWorkspace}/${validVal}`;
|
extendedVal = validVal.indexOf(' ') > -1 ? validVal.split(' ') : (validVal || './');
|
||||||
|
break;
|
||||||
|
case 'args':
|
||||||
|
extendedVal = validVal.split(' ');
|
||||||
break;
|
break;
|
||||||
case 'exclude':
|
case 'exclude':
|
||||||
case 'args':
|
|
||||||
case 'sshCmdArgs':
|
case 'sshCmdArgs':
|
||||||
extendedVal = validVal.split(',').map((item) => item.trim());
|
extendedVal = validVal.split(',').map((item) => item.trim());
|
||||||
break;
|
break;
|
||||||
|
@@ -17,7 +17,7 @@ const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Prom
|
|||||||
writeToFile({ dir: githubWorkspace, filename, content });
|
writeToFile({ dir: githubWorkspace, filename, content });
|
||||||
console.log(`Executing remote script: ssh -i ${privateKeyPath} ${sshServer}`);
|
console.log(`Executing remote script: ssh -i ${privateKeyPath} ${sshServer}`);
|
||||||
exec(
|
exec(
|
||||||
`DEBIAN_FRONTEND=noninteractive ssh -i ${privateKeyPath} ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" bash -s' < ${filename}`,
|
`DEBIAN_FRONTEND=noninteractive ssh -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" bash -s' < ${filename}`,
|
||||||
(err, data, stderr) => {
|
(err, data, stderr) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
const message = `⚠️ [CMD] Remote script failed: ${err.message}`;
|
const message = `⚠️ [CMD] Remote script failed: ${err.message}`;
|
||||||
|
@@ -2,6 +2,12 @@ const { execSync } = require('child_process');
|
|||||||
const nodeRsync = require('rsyncwrapper');
|
const nodeRsync = require('rsyncwrapper');
|
||||||
|
|
||||||
const nodeRsyncPromise = async (config) => new Promise((resolve, reject) => {
|
const nodeRsyncPromise = async (config) => new Promise((resolve, reject) => {
|
||||||
|
const logCMD = (cmd) => {
|
||||||
|
console.warn('================================================================');
|
||||||
|
console.log(cmd);
|
||||||
|
console.warn('================================================================');
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
nodeRsync(config, (error, stdout, stderr, cmd) => {
|
nodeRsync(config, (error, stdout, stderr, cmd) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -11,10 +17,12 @@ const nodeRsyncPromise = async (config) => new Promise((resolve, reject) => {
|
|||||||
console.error(stderr);
|
console.error(stderr);
|
||||||
console.error('❌️ [Rsync] stdout: ');
|
console.error('❌️ [Rsync] stdout: ');
|
||||||
console.error(stdout);
|
console.error(stdout);
|
||||||
console.error('❌ [Rsync] cmd: ', cmd);
|
console.error('❌ [Rsync] command: ');
|
||||||
|
logCMD(cmd);
|
||||||
reject(new Error(`${error.message}\n\n${stderr}`));
|
reject(new Error(`${error.message}\n\n${stderr}`));
|
||||||
} else {
|
} else {
|
||||||
console.log('[Rsync] cmd finished: ', cmd);
|
console.log('⭐ [Rsync] command finished: ');
|
||||||
|
logCMD(cmd);
|
||||||
resolve(stdout);
|
resolve(stdout);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -47,11 +55,13 @@ const rsyncCli = async ({
|
|||||||
privateKeyPath, args, sshCmdArgs
|
privateKeyPath, args, sshCmdArgs
|
||||||
}) => {
|
}) => {
|
||||||
console.log(`[Rsync] Starting Rsync Action: ${source} to ${rsyncServer}`);
|
console.log(`[Rsync] Starting Rsync Action: ${source} to ${rsyncServer}`);
|
||||||
if (exclude) console.log(`[Rsync] excluding folders ${exclude}`);
|
if (exclude && exclude.length > 0) console.log(`[Rsync] excluding folders ${exclude}`);
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
ssh: true,
|
ssh: true,
|
||||||
recursive: true
|
recursive: true,
|
||||||
|
onStdout: (data) => console.log(data.toString()),
|
||||||
|
onStderr: (data) => console.error(data.toString())
|
||||||
};
|
};
|
||||||
|
|
||||||
// RSYNC COMMAND
|
// RSYNC COMMAND
|
||||||
@@ -59,8 +69,7 @@ const rsyncCli = async ({
|
|||||||
return nodeRsyncPromise({
|
return nodeRsyncPromise({
|
||||||
...defaultOptions,
|
...defaultOptions,
|
||||||
src: source, dest: rsyncServer, excludeFirst: exclude, port: remotePort,
|
src: source, dest: rsyncServer, excludeFirst: exclude, port: remotePort,
|
||||||
privateKey: privateKeyPath, args, sshCmdArgs,
|
privateKey: privateKeyPath, args, sshCmdArgs
|
||||||
onStdout: (data) => console.log(data), onStderr: (data) => console.error(data)
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -6,23 +6,32 @@ RUN apt update
|
|||||||
|
|
||||||
RUN apt install openssh-server rsync sudo -y
|
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 "PubkeyAuthentication yes" >> /etc/ssh/sshd_config.d/pub.conf
|
||||||
RUN echo "AuthorizedKeysFile .ssh/authorized_keys" >> /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 mkdir -p /var/www/html
|
||||||
RUN chown -R test /var/www/html
|
RUN mkdir -p /var/www/html/test
|
||||||
|
RUN mkdir -p /var/www/html/test2
|
||||||
|
RUN chmod -R 775 /var/www/html
|
||||||
|
|
||||||
|
RUN useradd -rm -d /home/test -s /bin/bash -g root -G sudo -u 1000 test
|
||||||
|
RUN usermod -aG sudo test
|
||||||
RUN mkdir -p /home/test/.ssh
|
RUN mkdir -p /home/test/.ssh
|
||||||
RUN echo "$SSH_PUB_KEY" > /home/test/.ssh/authorized_keys
|
RUN echo "$SSH_PUB_KEY" > /home/test/.ssh/authorized_keys
|
||||||
RUN chmod 700 /home/test/.ssh
|
RUN chmod 700 /home/test/.ssh
|
||||||
RUN chown -R test /home/test/.ssh
|
RUN chown -R test /home/test/.ssh
|
||||||
|
|
||||||
|
RUN useradd -rm -d /home/test2 -s /bin/bash -g root -G sudo -u 1002 test2
|
||||||
|
RUN usermod -aG sudo test2
|
||||||
|
RUN mkdir -p /home/test2/.ssh
|
||||||
|
RUN echo "$SSH_PUB_KEY" > /home/test2/.ssh/authorized_keys
|
||||||
|
RUN chmod 700 /home/test2/.ssh
|
||||||
|
RUN chown -R test2 /home/test2/.ssh
|
||||||
|
|
||||||
RUN service ssh start
|
RUN service ssh start
|
||||||
|
|
||||||
RUN echo 'test:test' | chpasswd
|
RUN echo 'test:test' | chpasswd
|
||||||
|
RUN echo 'test2:test2' | chpasswd
|
||||||
|
|
||||||
EXPOSE 22
|
EXPOSE 22
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user