Shiny Loot
Shiny Loot

Reputation: 1

Github Actions pipeline terminates after 10 minutes with a timeout

I am trying to run a CI/CD pipeline through GitHub Actions. If it finishes within 10 minutes - there are no problems. But as soon as it runs for 10 minutes it gets terminated with an error:

Run Command Timeout
Error: Process completed with exit code 1.

If I re-run failed jobs - the process takes less than 10 minutes and is usually successful.

I tried adding

timeout-minutes: 100.

I tried dividing the job into separate granular steps. I tried adding for loop to print out a simple message while the job is running.

Here's my original yml file:

name: Build And Deploy (GCP)

   
on: 
  push:
    branches:
      - development
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    name: Deploy the latest changes from dev to prod
    timeout-minutes: 100

    steps:
      - name: Checkout the files
        uses: actions/checkout@v2

      - name: Deploy to main server
        uses: easingthemes/ssh-deploy@main
        env:
          SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY_DEV }}
          REMOTE_HOST: ${{ secrets.HOST_DNS_DEV }}
          REMOTE_USER: ${{ secrets.USERNAME_DEV }}
          TARGET: ${{ secrets.TARGET_DIR_DEV }}/web 

      - name: Executing remote ssh commands using ssh key
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.HOST_DNS_DEV }}
          username: ${{ secrets.USERNAME_DEV }}
          key: ${{ secrets.EC2_SSH_KEY_DEV }}
          script: |
            sudo apt -y update
            sudo  apt-get install -y python3 python3-pip python3-venv
            export PYTHON=$(which python3)
            yarn install           
            cd ${{ secrets.TARGET_DIR_DEV }}
            cp ./server/docker-compose.prod.yml -f .
            sudo docker compose -f docker-compose.prod.yml up frontend -d --build
            sudo docker system prune -a -f

Upvotes: 0

Views: 610

Answers (1)

Benjamin W.
Benjamin W.

Reputation: 52451

appleboy/ssh-action has an input parameter command_timeout, which defaults to 10m. You can adjust the timeout by setting a higher value.

I also recommend pinning the version of the action, instead of using @master, or else it might break randomly when something changes:

      - name: Executing remote ssh commands using ssh key
        uses: appleboy/[email protected]
        with:
          host: ${{ secrets.HOST_DNS_DEV }}
          username: ${{ secrets.USERNAME_DEV }}
          key: ${{ secrets.EC2_SSH_KEY_DEV }}
          command_timeout: 20m
          script: |
            # Your script

Upvotes: 3

Related Questions