Как выполнять несколько запросов postgresql в действиях github

Я пишу тест кода на python на github actions и я определил рабочий процесс.
но теперь я не знаю, как запустить несколько запросов для создания БД, пользователя, GRANT и т.д... .

вот мой рабочий процесс:

name: lint_python
on: [pull_request, push]
jobs:
  lint_python:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:latest
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: postgres
          POSTGRES_PORT: 5432
        ports:
          - 5432:5432
        
        # needed because the postgres container does not provide a healthcheck
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
      - name: Install PostgreSQL client
        run: |
          apt-get update
          apt-get install --yes postgresql-client
      
      - name: Query database
        run: psql -h postgres -d postgres_db -U postgres_user -c "SELECT 'CREATE DATABASE redteam_toolkit_db' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'redteam_toolkit_db');"
        run: psql -h postgres -d postgres_db -U postgres_user -c "CREATE ROLE redteamuser with SUPERUSER CREATEDB LOGIN ENCRYPTED PASSWORD '147r258r';"
        run: psql -h postgres -d postgres_db -U postgres_user -c "GRANT ALL PRIVILEGES ON DATABASE redteam_toolkit_db TO redteamuser;"
        run: psql -h postgres -d postgres_db -U postgres_user -c "ALTER DATABASE redteam_toolkit_db OWNER TO redteamuser;"
        env:
          PGPASSWORD: postgres
          
      # https://www.hacksoft.io/blog/github-actions-in-action-setting-up-django-and-postgres#resources
      - run: sudo apt-get install libpq-dev
      - run: pip install --upgrade pip wheel
      - run: pip install bandit black codespell flake8 flake8-bugbear
                         flake8-comprehensions isort mypy pyupgrade safety
      - run: bandit --recursive  --skip B106,B110,B404,B602,B603,B607 .
      - run: black --check . || true
      - run: codespell
      - run: flake8 . --count --select=C,E5,E9,F63,F7,F82 --max-complexity=28
                              --max-line-length=220 --show-source --statistics
      - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=88
                      --show-source --statistics
      - run: isort --check-only --profile black . || true
      - run: |
          pip install -r requirements.txt
          mkdir --parents --verbose .mypy_cache
      - run: mypy --ignore-missing-imports --install-types --non-interactive .
      - run: python manage.py makemigrations
      - run: python manage.py migrate
        env:  # https://stackoverflow.com/questions/61670081
          SECRET_KEY: 96fc8cf096d12574a61caf5a93ac4c9e3abc37094144971a1a
      - run: python manage.py test
        env:  # https://stackoverflow.com/questions/61670081
          SECRET_KEY: 96fc8cf096d12574a61caf5a93ac4c9e3abc37094144971a1a
      - run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
      - run: safety check

я хочу создать:
пользователя базы данных : redteamuser
с паролем.
Имя БД: redteam_toolkit_db

где моя проблема?
Я очень ценю ваше время, и с нетерпением жду вашего ответа.

Вернуться на верх