ssh-deploy/.github/workflows/e2e.yml

180 lines
6.3 KiB
YAML
Raw Normal View History

2022-12-29 22:14:51 +00:00
name: e2e Test
on:
2022-12-30 14:25:45 +00:00
push:
2023-01-03 02:11:47 +00:00
branches: [ 'main' ]
2022-12-29 22:14:51 +00:00
env:
TEST_HOST_DOCKER: ./test
2022-12-31 01:43:17 +00:00
TEST_USER: test
TEST_USER2: test2
2022-12-29 22:14:51 +00:00
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
2023-01-03 02:03:07 +00:00
# : ---------------------------------------------------------------
# : START E2E Test Specific - steps
# : ----------------------------------------------------------------
2023-01-03 02:03:07 +00:00
- name: E2E Test Specific - Clean up old test files
2022-12-30 09:29:20 +00:00
run: |
docker stop ssh-host-container || true && docker rm ssh-host-container || true
2023-01-03 02:03:07 +00:00
- name: E2E Test Specific - Create ssh keys
2022-12-29 22:14:51 +00:00
run: |
2022-12-30 09:29:20 +00:00
echo $HOME
ls -la $HOME
2022-12-29 22:14:51 +00:00
ssh-keygen -m PEM -t rsa -b 4096 -f "$HOME/.ssh/id_rsa" -N ""
2022-12-30 15:04:25 +00:00
eval `ssh-agent -s`
2022-12-30 15:01:47 +00:00
ssh-add "$HOME/.ssh/id_rsa"
ssh-add -l
2022-12-31 02:15:04 +00:00
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_ENV
2022-12-30 09:29:20 +00:00
cat $HOME/.ssh/id_rsa >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
2022-12-29 22:14:51 +00:00
2023-01-03 02:03:07 +00:00
- name: E2E Test Specific - Build Host Server Image
2022-12-30 09:29:20 +00:00
working-directory: ${{ env.TEST_HOST_DOCKER }}
2022-12-29 22:14:51 +00:00
run: |
docker build \
-t ssh-host-image . \
--build-arg SSH_PUB_KEY="$(cat $HOME/.ssh/id_rsa.pub)"
2022-12-31 01:43:17 +00:00
docker run -d -p 8822:22 --name=ssh-host-container ssh-host-image
2022-12-30 13:29:31 +00:00
docker exec ssh-host-container sh -c "hostname --ip-address" > ip.txt
2022-12-31 02:15:04 +00:00
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
2022-12-30 13:29:31 +00:00
cat ip.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
2022-12-29 22:14:51 +00:00
2023-01-03 02:03:07 +00:00
- name: E2E Test Specific - Create project file
2022-12-29 22:14:51 +00:00
run: |
mkdir test_project2 && cd "$_"
truncate -s 5MB info2.txt
cd ../
mkdir test_project && cd "$_"
2022-12-29 22:14:51 +00:00
touch index.html
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
2023-01-02 21:40:20 +00:00
truncate -s 50MB image.svg
truncate -s 5MB info.txt
2023-01-02 21:30:57 +00:00
truncate -s 500MB big_file.txt
mkdir skip_dir && cd "$_"
truncate -s 5MB text_in_skip_dir.txt
cd ../
2022-12-29 22:14:51 +00:00
cat index.html
echo "test_project:" && ls -lR
echo "skip_dir:" && ls -lR skip_dir
2023-01-03 02:03:07 +00:00
# ----------------------------------------------------------------
# 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
2022-12-29 22:28:40 +00:00
- name: e2e Test ssh-deploy action - Target 1
2023-01-03 02:11:47 +00:00
uses: easingthemes/ssh-deploy@main
2022-12-31 02:15:04 +00:00
env:
# Shared ENV Vars created in previous steps
2022-12-31 02:15:04 +00:00
REMOTE_USER: ${{ env.TEST_USER }}
TARGET: /var/www/html/${{ env.TEST_USER }}
- name: e2e Test ssh-deploy action - Target 2
uses: easingthemes/ssh-deploy@main
env:
# Shared ENV Vars created in previous steps
REMOTE_USER: ${{ env.TEST_USER2 }}
TARGET: /var/www/html/${{ env.TEST_USER2 }}
2023-02-21 13:38:27 +00:00
- name: e2e Test ssh-deploy action - Default values
2023-02-21 13:50:41 +00:00
uses: easingthemes/ssh-deploy@main
2023-02-21 13:38:27 +00:00
env:
# Shared ENV Vars created in previous steps
REMOTE_USER: ${{ env.TEST_USER }}
2023-01-03 18:29:28 +00:00
e2e-v3:
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 - Target 1
2023-01-03 22:15:21 +00:00
uses: easingthemes/ssh-deploy@v3
2023-01-03 18:29:28 +00:00
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