contentmonster/.forgejo/workflows/test.yml
Kumi d4afc756c4
Some checks failed
Test! / test (push) Failing after 8s
feat(workflows): Add Docker installation step
To facilitate the execution of tests within a controlled environment, Docker is now installed as part of the CI testing workflow. This addition ensures that any Docker-dependent steps, specifically the building and running of an SSH Server Docker container, execute seamlessly. Previously, the assumption was that Docker would be pre-installed on the runner, which could lead to inconsistencies or failures in environments where this was not the case. By explicitly including the Docker installation step, the workflow becomes more portable and resilient across different CI execution environments.
2024-04-22 16:58:23 +02:00

44 lines
1.2 KiB
YAML

name: Test!
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Generate SSH key pair
run: |
ssh-keygen -t rsa -b 4096 -f my_ssh_key -N ""
- name: Install Docker
run: |
sudo apt-get update
sudo apt-get install -y docker.io
- name: Build and run SSH Server Docker Container
run: |
docker build -t my-ssh-server ./ci-tests/Dockerfile
docker run -d -p 2222:22 --name ssh-server my-ssh-server
- name: Copy public key to Docker container
run: |
docker cp my_ssh_key.pub ssh-server:/home/replication/.ssh/authorized_keys
docker exec ssh-server chown replication:replication /home/replication/.ssh/authorized_keys
docker exec ssh-server chmod 600 /home/replication/.ssh/authorized_keys
- name: Trust SSH server's host key (to prevent interactive prompt)
run: |
ssh-keyscan -p 2222 -H localhost >> ~/.ssh/known_hosts
- name: Connect to SSH server using SSH key
run: |
ssh -i my_ssh_key -p 2222 root@localhost echo "SSH connection successful"