Skip to content

Commit

Permalink
Use GITHUB_ENV to pass secrets into docker build.
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rj1k committed Jun 22, 2024
1 parent 3dc18db commit 1289058
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions .github/actions/docker-build-artifacts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,34 @@ inputs:
runs:
using: "composite"
steps:

- name: Set up QEMU for Docker
uses: docker/setup-qemu-action@v3

- name: Set up Python
uses: actions/setup-python@v5

- name: Append REPO_PASSWORD and DEPLOYMENT_TOKEN to GITHUB_ENV
env:
REPO_PASSWORD: ${{ secrets.REPO_PASSWORD }}
DEPLOYMENT_TOKEN: ${{ secrets.DEPLOYMENT_TOKEN }}
shell: python
run: |
import os
env_vars = {
'REPO_PASSWORD': os.getenv('REPO_PASSWORD'),
'DEPLOYMENT_TOKEN': os.getenv('DEPLOYMENT_TOKEN')
}
with open(os.getenv('GITHUB_ENV'), 'at') as github_env:
for key, value in env_vars.items():
github_env.write(f"{key}={value}\n")
- name: Build Docker image
shell: bash
working-directory: ${{ inputs.WORKING_DIRECTORY }}
run: |
env REPO_PASSWORD='${{ env.REPO_PASSWORD }}' DEPLOYMENT_TOKEN='${{ env.DEPLOYMENT_TOKEN }}' docker build \
docker build \
--build-arg BUILD_NUMBER="${GITHUB_RUN_ID}" \
--build-arg GIT_SHA="$(echo ${GITHUB_SHA} | cut -c1-10)" \
--build-arg MAINTAINER="${{ inputs.MAINTAINER }}" \
Expand Down

0 comments on commit 1289058

Please sign in to comment.