Sleep command runs forever

I’m trying to access my local machine via openfortivpn client to run some deploy scripts.

The problem is: after I run the command to connect to VPN, I need to use the “sleep” command to wait for connection. The sleep command runs forever. It happens only when I set the openfortivpn command to run in the background.

name: Deploy

on:
  push:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install
        run: |
          sudo apt-get update
          sudo apt-get install openfortivpn -y
          sudo apt-get install ppp

      - name: Run
        continue-on-error: true
        run: |
          sudo openfortivpn ... &

      - name: Wait VPN connection
        run: |
          sleep 30
          # This step runs forever

      - name: ...

There are GitHub Actions that allow you to connect to the runner via SSH, such as:

Maybe have a look at how they do it and try to replicate it.

At the core, they seem to repeatedly wait for 5 seconds in their JavaScript code:

const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
...
await sleep(5000)