How to specify postgres DB parameters during Github Action Python build for Azure?
I have a Django web application I'm trying to deploy to Azure. I'm following this tutorial on how to set up the project. During the build I'm trying to run migrations on the DB, with the following command:
env:
WEBSITE_HOSTNAME: 'something'
DBHOST: ${{ secrets.DBHOST }}
DBNAME: ${{ secrets.DBNAME }}
DBPASSWORD: ${{ secrets.DBPASSWORD }}
DBUSER: ${{ secrets.DBUSER }}
DBPASS: ${{ secrets.DBPASS }}
DBPORT: ${{ secrets.DBPORT }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.10'
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt
- name: Make migrations and run migrations
run: python ./appname/manage.py migrate
However, this step fails with the following error:
django.db.utils.OperationalError: could not translate host name "***.***.database.azure.com" to address: Name or service not known
I'm referring to these values in the settings.py like this:
hostname = os.environ['DBHOST']
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': os.environ['DBNAME'],
'USER': os.environ['DBUSER'],
'PASSWORD': os.environ['DBPASS'],
'PORT': os.environ['DBPORT'],
'HOST': hostname + ".postgres.database.azure.com" if 'WEBSITE_HOSTNAME' in os.environ else os.environ['DBHOST']
}
}
I have inserted the DBNAME, DBHOST, etc. values shown on the screenshot as app secrets into github, so I'm really not sure why it is not finding them. Can anyone point out please what am I missing here?