GitHub Actions scenarios to deploy using Docker on EC2 due to network permission issues
I've been working on this all day and I can't seem to get I'm collaborating on a project where I'm working with a frustrating scenario with my GitHub Actions workflow that attempts to build and deploy a Docker container to my EC2 instance..... The workflow runs successfully up to the deployment step, but I receive the following behavior: ``` behavior: Get "http://<EC2_IP>:<PORT>/some-endpoint": dial tcp <EC2_IP>:<PORT>: connect: connection timed out ``` I've confirmed that the EC2 instance is running and accessible from my local machine. The security group associated with the instance allows inbound traffic on the specified port, and I've verified that the Docker container is listening on that port. Here's the relevant portion of my `.github/workflows/deploy.yml` file: ```yaml name: Deploy to EC2 on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 - name: Docker build run: | docker build -t my-app . - name: Docker login run: | echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Push Docker image run: | docker tag my-app:latest myrepo/my-app:latest docker push myrepo/my-app:latest - name: Deploy to EC2 run: | ssh -o StrictHostKeyChecking=no ubuntu@<EC2_IP> "docker pull myrepo/my-app:latest && docker run -d -p <PORT>:<PORT> myrepo/my-app:latest" ``` I have ensured that SSH keys are set up correctly and that the `DOCKER_PASSWORD`, `DOCKER_USERNAME`, and EC2 IP are all stored as GitHub secrets. I can SSH into the EC2 instance from my local terminal without any issues. However, the Action seems to be unable to establish a connection to the Docker service running on the EC2 instance. Could there be a configuration scenario on the EC2 instance, or is it possible that GitHub Actions is trying to connect from a different network that isn't whitelisted in the security group? Any suggestions on how to troubleshoot this would be greatly appreciated! This issue appeared after updating to Yaml 3.11. Has anyone else encountered this? Could this be a known issue?