'How to run two commands on Github Actions instance one after another?

So question seems easy but let me start with this, ";" "&" does not work.

The two commands to be ran on Github actions instance in CI/CD pipeline :

  1. python3 manage.py runserver
  2. python3 abc.py

After putting the command in the yaml file, only the first command runs and then the workflow is stuck there only and does not executes the second command.

I have tried putting in two separate blocks in workflow yaml file but no luck.



Solution 1:[1]

There are two to run commands one after another on Github Actions.

On the same step:

   steps:
      - name: Run both python files
        run: |
          python manage.py runserver
          python abc.py

On different steps (that will run in sequence):

   steps:
      - name: Run first python file
        run: python manage.py runserver

      - name: Run second python file
        run: python abc.py        

Also, you don't need to inform python3, just python is enough, as you will use the setup/python action informing the version first.

Therefore, your whole workflow would probably look like this:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository content
        uses: actions/[email protected]

      - name: Setup Python Version
        uses: actions/setup-python@v2
        with:
          python-version: 3.8

      - name: Install Python dependencies
        run: python -m pip install --upgrade pip [...] # if necessary

      - name: Execute Python scripts
        run: |
          python manage.py runserver
          python abc.py

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GuiFalourd