title: Setup postgres in Github Actions for Django
body: <p>I'm currently working on a website right now on Django. On my computer, I am running it on Docker with a postgres database. Here's the docker-compose file I have:</p>
  <pre><code>version: '3'
  
  services:
      db:
          image: postgres
          environment:
              - POSTGRES_DB=postgres
              - POSTGRES_USER=postgres
              - POSTGRES_PASSWORD=postgres
  
  
      web:
          build: .
          volumes:
              - .:/usr/src/app
          ports:
              - &quot;8000:8000&quot;
  </code></pre>
  <p>And here's the relevant part in settings.py</p>
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.postgresql',
          'NAME': 'postgres',
          'USER': 'postgres',
          'PASSWORD': 'postgres',
          'HOST': 'db',
          'PORT': 5432,
      }
  }
  </code></pre>
  <p>When I run my tests in the docker container with this setup, it works find and the tests run. However, in github actions, it doesn't work. Here's my workflow file:</p>
  <pre><code>name: Django CI
  
  on: push
  
  
  jobs:
    build:
  
      runs-on: ubuntu-latest
  
      strategy:
        max-parallel: 4
        matrix:
          python-version: [3.7, 3.8]
  
      services:
        db:
          image: postgres
          env:
            POSTGRES_DB: postgres
            POSTGRES_USER: postgres
            POSTGRES_PASSWORD: postgres
          ports:
            - 5432:5432
  
      steps:
      - uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v1
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install Dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
      - name: Run Tests
        run: |
          python manage.py test
  </code></pre>
  <p>When this runs in github actions, I get the following error:</p>
  <pre><code>django.db.utils.OperationalError: could not translate host name &quot;db&quot; to address: Temporary failure in name resolution
  </code></pre>
  <p>Could someone please help me with this, and please let me know if you need anymore code.</p>