'Django not finding environment variables set by Github Actions
I have a Github Action that creates a Docker image, and the issue I am having is that when I docker logs backend I get an error like:
File "/usr/src/app/api/settings/common.py", line 165, in <module>
AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
File "/usr/local/lib/python3.9/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'AWS_ACCESS_KEY_ID'
As part of my .yml for GitHub I have this code which from research should inject the environment variables into my Docker image.
jobs:
build_and_deploy_backend__production:
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v2
- name: Build image
run: docker build -t backend .
env:
AWS_ACCESS_KEY_ID: ${{ secrets.GLOBAL_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.GLOBAL_AWS_SECRET_ACCESS_KEY }}
I am wondering if there is anything obvious that I am doing wrong.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

