easingthemes-ssh-deploy/.github/workflows/e2e.yml
Dragan Filipovic e577b525ca env2
2022-12-30 15:46:37 +01:00

81 lines
2.3 KiB
YAML

name: e2e Test
on:
push:
branches: [ 'feature/add-tests' ]
env:
TEST_HOST_DOCKER: ./test
TEST_USER: kaja
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Clean up old test files
run: |
docker stop ssh-host-container || true && docker rm ssh-host-container || true
- name: 1. Create ssh keys
run: |
echo $HOME
ls -la $HOME
ssh-keygen -m PEM -t rsa -b 4096 -f "$HOME/.ssh/id_rsa" -N ""
# ssh-add "$HOME/.ssh/id_rsa"
# ssh-add -l
echo "EXAMPLE_SSH_PRIVATE_KEY<<EOF" >> $GITHUB_ENV
cat $HOME/.ssh/id_rsa >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: 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 }}"
docker run -d --name=ssh-host-container ssh-host-image
docker exec ssh-host-container sh -c "hostname --ip-address" > ip.txt
echo "EXAMPLE_REMOTE_HOST<<EOF" >> $GITHUB_ENV
cat ip.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
- name: Create project file
run: |
mkdir test_project
cd test_project
touch index.html
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
cat index.html
- name: e2e Test local ssh-deploy action
run: |
npm ci
npm run build
node ./src/test.js
env:
SSH_PRIVATE_KEY: ${{ env.EXAMPLE_SSH_PRIVATE_KEY }}
ARGS: "-rltgoDzvO"
SOURCE: "test_project/"
REMOTE_HOST: ${{ env.EXAMPLE_REMOTE_HOST }}
REMOTE_USER: ${{ env.TEST_USER }}
TARGET: "/var/www/html/"
EXCLUDE: "/dist/, /node_modules/"
# - name: e2e Test published ssh-deploy action
# uses: easingthemes/ssh-deploy@main
# env:
# SSH_PRIVATE_KEY: $EXAMPLE_SSH_PRIVATE_KEY
# ARGS: "-rltgoDzvO"
# SOURCE: "test_project/"
# REMOTE_HOST: $EXAMPLE_REMOTE_HOST
# REMOTE_USER: $TEST_USER
# TARGET: "/var/www/html/"
# EXCLUDE: "/dist/, /node_modules/"