showing logs #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run tests (aimed at SSH server) | |
on: | |
push | |
#pull_request: | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Generate SSH key | |
id: ssh-key | |
run: | | |
ssh-keygen -t rsa -b 4096 -f /tmp/ssh_key -N "" | |
ssh_key_pub=$(cat /tmp/ssh_key.pub) | |
echo "::set-output name=public_key::${ssh_key_pub}" | |
- name: Start Docker container | |
run: | | |
docker run -d -p 22222:22 --name test_container -e AUTHORIZED_KEYS="${{ steps.ssh-key.outputs.public_key }}" diniscruz/python_with_ssh | |
- name: Run a simple SSH command | |
run: | | |
ls -la /tmp | |
chmod 600 /tmp/ssh_key | |
ssh -o StrictHostKeyChecking=no -i /tmp/ssh_key root@localhost -p 22222 echo "SSH connection successful" | |
- name: Viewing docker logs | |
run: | | |
docker ps | |
docker logs test_container | |
# - name: Run tests | |
# run: | | |
# # Add your test commands here | |
# docker exec test_container <your_test_command> | |
- name: Stop and remove Docker container | |
run: | | |
docker stop test_container | |
docker rm test_container |