mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-06-21 12:02:09 +10:00
feat: Add multi source and multi target support
This commit is contained in:
parent
98ee38d52e
commit
73a65ec97c
9 changed files with 227 additions and 70 deletions
79
.github/workflows/e2e.yml
vendored
79
.github/workflows/e2e.yml
vendored
|
@ -3,25 +3,11 @@ name: e2e Test
|
|||
on:
|
||||
push:
|
||||
branches: [ 'feature/multi-src' ]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ARGS:
|
||||
description: 'ARGS'
|
||||
required: true
|
||||
default: '-rltgoDzvO --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
|
||||
TEST_USER2: test2
|
||||
|
||||
jobs:
|
||||
e2e:
|
||||
|
@ -31,11 +17,15 @@ jobs:
|
|||
- name: Checkout
|
||||
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: |
|
||||
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
||||
|
||||
- name: Create ssh keys
|
||||
- name: [E2E Test Specific] Create ssh keys
|
||||
run: |
|
||||
echo $HOME
|
||||
ls -la $HOME
|
||||
|
@ -47,13 +37,12 @@ jobs:
|
|||
cat $HOME/.ssh/id_rsa >> $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 }}
|
||||
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 }}"
|
||||
--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
|
||||
|
@ -61,7 +50,7 @@ jobs:
|
|||
echo "EOF" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Create project file
|
||||
- name: [E2E Test Specific] Create project file
|
||||
run: |
|
||||
mkdir test_project2 && cd "$_"
|
||||
truncate -s 5MB info2.txt
|
||||
|
@ -76,24 +65,38 @@ jobs:
|
|||
truncate -s 5MB text_in_skip_dir.txt
|
||||
cd ../
|
||||
cat index.html
|
||||
echo "test_project:" && ls -l
|
||||
echo "skip_dir:" && ls -l skip_dir
|
||||
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=-rltgoDzvOR --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@feature/multi-src
|
||||
env:
|
||||
# ENV Vars created in previous steps:
|
||||
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
|
||||
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
|
||||
# Shared ENV Vars created in previous steps
|
||||
REMOTE_USER: ${{ env.TEST_USER }}
|
||||
ARGS: ${{ github.event.inputs.ARGS || '-rltgoDzvO --delete --chmod=ugo=rwX --progress' }}
|
||||
SSH_CMD_ARGS: ${{ github.event.inputs.SSH_CMD_ARGS || '-o StrictHostKeyChecking=no, -o UserKnownHostsFile=/dev/null' }}
|
||||
SOURCE: ["test_project/, test_project2/"]
|
||||
TARGET: "/var/www/html/"
|
||||
EXCLUDE: ${{ github.event.inputs.EXCLUDE || 'skip_dir/, /node_modules/' }}
|
||||
SCRIPT_BEFORE: |
|
||||
whoami
|
||||
ls -al /var/www/html/
|
||||
SCRIPT_AFTER: |
|
||||
ls -al /var/www/html/
|
||||
echo $RSYNC_STDOUT
|
||||
TARGET: /var/www/html/${{ env.TEST_USER }}
|
||||
|
||||
- name: e2e Test ssh-deploy action - Target 2
|
||||
uses: easingthemes/ssh-deploy@feature/multi-src
|
||||
env:
|
||||
# Shared ENV Vars created in previous steps
|
||||
REMOTE_USER: ${{ env.TEST_USER2 }}
|
||||
TARGET: /var/www/html/${{ env.TEST_USER2 }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue