Hi All, need help-
I want pass environment variable (value) from Git Action’s deployment.yaml to dockerfile", is that something I can do ? Basically I have a python script which has static value given for AWS secret, I want to make it dynamic based on the environment(stage, prod, etc…). I have an Environment variable defined in deploy.yaml in github actions workflow, I want to pass that environment value into dockerfile . Can i do that ? Any guidance would be a great help
So basically the question is how to configure the GitHub Action to pass the variables into the build.
The docker perspective is quite simple: declare ARG instructions in your Dockerfile, and pass their values in with build args. See: https://docs.docker.com/reference/dockerfile/#arg
Now you need to figure out how to configure the GitHub Action to pass the build args into the build.
Hello,
In GitHub Actions, pass build arguments (ARG) to the Docker build using build-args in docker/build-push-action:
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: your-dockerhub-username/your-image-name:latest
build-args: |
API_URL=${{ secrets.API_URL }}
NEXT_PUBLIC_API_KEY=${{ secrets.NEXT_PUBLIC_API_KEY }}
Add secrets in GitHub Settings → Actions → Secrets and variables.
1 Like
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.