2022-12-29 22:14:51 +00:00
|
|
|
name: e2e Test
|
|
|
|
|
|
|
|
on:
|
2022-12-30 14:25:45 +00:00
|
|
|
push:
|
2023-01-02 20:08:00 +00:00
|
|
|
branches: [ 'main' ]
|
2023-01-02 20:44:34 +00:00
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
ARGS:
|
|
|
|
description: 'ARGS'
|
|
|
|
required: true
|
2023-01-02 21:30:57 +00:00
|
|
|
default: '-rltgoDzvO --delete --chmod=ugo=rwX --progress'
|
2023-01-02 20:44:34 +00:00
|
|
|
EXCLUDE:
|
|
|
|
description: 'EXCLUDE'
|
|
|
|
required: true
|
|
|
|
default: '/dist/, /node_modules/'
|
|
|
|
SSH_CMD_ARGS:
|
|
|
|
description: 'SSH_CMD_ARGS'
|
|
|
|
required: true
|
2023-01-02 21:30:57 +00:00
|
|
|
default: '-o StrictHostKeyChecking=no, -o UserKnownHostsFile=/dev/null'
|
2023-01-02 20:44:34 +00:00
|
|
|
|
2022-12-29 22:14:51 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
TEST_HOST_DOCKER: ./test
|
2022-12-31 01:43:17 +00:00
|
|
|
TEST_USER: test
|
2022-12-29 22:14:51 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
e2e:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2022-12-30 09:29:20 +00:00
|
|
|
- name: Clean up old test files
|
|
|
|
run: |
|
|
|
|
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
|
|
|
|
2022-12-31 02:15:04 +00:00
|
|
|
- name: 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
|
|
|
|
|
|
|
- name: 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 . \
|
2022-12-31 01:43:17 +00:00
|
|
|
--build-arg SSH_PUB_KEY="$(cat $HOME/.ssh/id_rsa.pub)" \
|
2022-12-30 13:29:31 +00:00
|
|
|
--build-arg ssh_user="${{ env.TEST_USER }}"
|
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
|
|
|
|
|
|
|
- name: Create project file
|
|
|
|
run: |
|
2022-12-30 09:29:20 +00:00
|
|
|
mkdir test_project
|
|
|
|
cd test_project
|
2022-12-29 22:14:51 +00:00
|
|
|
touch index.html
|
2023-01-02 21:40:20 +00:00
|
|
|
truncate -s 50MB image.svg
|
|
|
|
truncate -s 5MB text.txt
|
2023-01-02 21:30:57 +00:00
|
|
|
truncate -s 500MB big_file.txt
|
2022-12-29 22:14:51 +00:00
|
|
|
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
|
|
|
cat index.html
|
2023-01-02 21:40:20 +00:00
|
|
|
ls -l
|
2022-12-29 22:28:40 +00:00
|
|
|
|
2022-12-30 14:48:53 +00:00
|
|
|
- name: e2e Test published ssh-deploy action
|
2023-01-02 20:08:00 +00:00
|
|
|
uses: easingthemes/ssh-deploy@main
|
2022-12-31 02:15:04 +00:00
|
|
|
env:
|
2023-01-02 20:13:46 +00:00
|
|
|
# ENV Vars created in previous steps:
|
2022-12-31 08:48:17 +00:00
|
|
|
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
|
2023-01-02 20:08:00 +00:00
|
|
|
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
|
2022-12-31 02:15:04 +00:00
|
|
|
REMOTE_USER: ${{ env.TEST_USER }}
|
2023-01-02 21:30:57 +00:00
|
|
|
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' }}
|
2022-12-30 14:48:53 +00:00
|
|
|
SOURCE: "test_project/"
|
|
|
|
TARGET: "/var/www/html/"
|
2023-01-02 21:02:16 +00:00
|
|
|
EXCLUDE: ${{ github.event.inputs.EXCLUDE || '/dist/, /node_modules/' }}
|
2023-01-02 20:06:33 +00:00
|
|
|
SCRIPT_BEFORE: |
|
|
|
|
whoami
|
|
|
|
ls -al
|
|
|
|
SCRIPT_AFTER: |
|
|
|
|
whoami
|
|
|
|
ls -al
|
|
|
|
echo $RSYNC_STDOUT
|