MAD-I-T / magento-actions

Github deployment actions for Magento 2
MIT License
101 stars 36 forks source link

Connection timed out #38

Closed jonatanaxe closed 1 year ago

jonatanaxe commented 1 year ago

ssh: connect to host port 22: Connection timed out

Hey guys I'm having an error with the ssh connection, has anyone else had this problem, I've generated the ssh keys several times, my server is from aws

name: m2-actions-test
on: [push]

jobs:
  magento2-build:
    runs-on: self-hosted
    container: ubuntu
    name: 'm2 unit tests & build'
    services:
      mysql:
        image: docker://mysql:8.0
        env:
          MYSQL_ROOT_PASSWORD: magento
          MYSQL_DATABASE: magento
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      elasticsearch:
        image: docker://elasticsearch:7.1.0
        ports:
          - 9200:9200
        options: -e="discovery.type=single-node" --health-cmd="curl http://localhost:9200/_cluster/health" --health-interval=10s --health-timeout=5s --health-retries=10
    steps:
    - name: Public IP
      id: ip
      uses: haythem/public-ip@v1.3

    - name: Print Public IP
      run: |
        echo ${{ steps.ip.outputs.ipv4 }}
        echo ${{ steps.ip.outputs.ipv6 }}

    - uses: actions/checkout@v1
      with:
        submodules: recursive
    # - name: 'this step starts static testing the code'
    #   if: always()
    #   uses: MAD-I-T/magento-actions@v3.16
    #   env:
    #     COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
    #   with:
    #     php: '8.1'
    #     process: 'unit-test'
    #     elasticsearch: 1
    - name: 'this step will build an magento artifact'
      uses: MAD-I-T/magento-actions@v3.16
      env:
        COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
      with:
        php: '8.1'
        process: 'build'
        elasticsearch: 1

    - name: 'starts magento2 zero downtime deploy with no permission check'
      if: success()
      uses: MAD-I-T/magento-actions@v3.16
      env:
        COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
        BUCKET_COMMIT: bucket-commit-${{github.sha}}.tar.gz
        MYSQL_ROOT_PASSWORD: magento
        MYSQL_DATABASE: magento
        HOST_DEPLOY_PATH: ${{secrets.STAGE_HOST_DEPLOY_PATH}}
        HOST_DEPLOY_PATH_BUCKET: ${{secrets.STAGE_HOST_DEPLOY_PATH}}/bucket
        SSH_PRIVATE_KEY: ${{secrets.STAGE_SSH_PRIVATE_KEY}}
        SSH_CONFIG: ${{secrets.STAGE_SSH_CONFIG}}
        WRITE_USE_SUDO: false
      with:
        php: '8.1'
        deployer: 'no-permission-check'
        process: 'deploy-staging'

    - name: 'unlock php deployer if the deployment fails'
      if: failure() || cancelled()
      uses: MAD-I-T/magento-actions@v3.16
      env:
        COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}}
        BUCKET_COMMIT: bucket-commit-${{github.sha}}.tar.gz
        MYSQL_ROOT_PASSWORD: magento
        MYSQL_DATABASE: magento
        HOST_DEPLOY_PATH: ${{secrets.STAGE_HOST_DEPLOY_PATH}}
        HOST_DEPLOY_PATH_BUCKET: ${{secrets.STAGE_HOST_DEPLOY_PATH}}/bucket
        SSH_PRIVATE_KEY: ${{secrets.STAGE_SSH_PRIVATE_KEY}}
        SSH_CONFIG: ${{secrets.STAGE_SSH_CONFIG}}
        WRITE_USE_SUDO: false
      with:
        php: '8.1'
        process: 'cleanup-staging' 
seyuf commented 1 year ago

Hi @jonatanaxe,

The issue seems to not come from the ssh key and/or ssh_config. But from your whitelisting process. I don't get why you're using ( haythem/public-ip@v1.3) ? As you seem to already be running on a self-hosted runner? (i.e runs-on: self-hosted). Just whitelist incoming traffic from your runner ip in your deployment instance security group rules? The haythem action seems to be for people using github public / shared runners. BTW, we strongly recommend using self-hosted runners, for obvious security reasons. But of course not everybody can't afford that.

jonatanaxe commented 1 year ago

Hi seyuf

Thanks for the quick response

I used haythem/public-ip@v1.3* because in the beginning we were trying to use github's runner more by changing the ip all the time, it didn't work out very well.

But we were running runner on the same magento server so it was giving error in ssh lol

Now we put the runner on another server and it worked :D

Thank you for your help @seyuf

seyuf commented 1 year ago

^^, it can happen to the best of us. Also, for posterity, all your action does is getting the IP and set it as server env. Which is pretty trivial and can be done with a simple curl ifconfig.me. For those, using public/shared runners and are on aws. What this guy does is a lot sexier, if one want to automate the whitelisting process.

Anyway, im closing this then.

jonatanaxe commented 1 year ago

^^, it can happen to the best of us. Also, for posterity, all your action does is getting the IP and set it as server env. Which is pretty trivial and can be done with a simple curl ifconfig.me. For those, using public/shared runners and are on aws. What this guy does is a lot sexier, if one want to automate the whitelisting process.

Anyway, im closing this then.

Very cool, now I understand better lol