Skip to content

Commit

Permalink
fix ENV setting error in Dockerfile
Browse files Browse the repository at this point in the history
modify print var node script
  • Loading branch information
slow-groovin committed Oct 17, 2024
1 parent 2d2506f commit fe86899
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
branches: [ "environment" ]

# two item set in github repo's setting-> secrets and variables -> action:
# 1. secrets: SECRET_IN_REPO: <secret in repo>
# 2. variables: VAR_IN_REPO: <var in repo>
# 1. secrets: SECRET_IN_REPO: "<secret in repo>"
# 2. variables: VAR_IN_REPO: "<var in repo>"

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions environment/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ RUN echo "[Print in Dockerfile Scope beginning]1.$VAR_REPO, 2.$SECRET_IN_REPO, 3
# declare arg,on by this it can read args from `build-args:` setting in environment.yml, as well as `--build-arg` in docker build command
ARG BUILD_ARG1

# set var in dockerfile scope
ENV VAR_IN_DOCKERFILE=<var in dockerfile>
# set var in dockerfile scope, `"` is required
ENV VAR_IN_DOCKERFILE="<var in dockerfile>"

RUN echo "[Print Dockerfile args/env]1.$BUILD_ARG1, 2.$VAR_IN_DOCKERFILE"

Expand Down
6 changes: 5 additions & 1 deletion environment/printVarsByActionRun.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
console.log('[Print in action running by script]:',process.env)
const envKeys=['VAR_REPO', 'SECRET_IN_REPO', 'VAR_IN_JOB1', 'VAR_IN_STEP1', 'VAR_IN_RUN','BUILD_ARG1','SECRETS1','SECRET_ENV_1']
console.log('[Print in action running by script]:',process.env)
envKeys.forEach(key=>{
console.log(key,":",process.env[key])
})
6 changes: 5 additions & 1 deletion environment/printVarsByDockerfile.js
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
console.log('[Print in Dockerfile running]:',process.env)
const envKeys=['VAR_REPO', 'SECRET_IN_REPO', 'VAR_IN_JOB1', 'VAR_IN_STEP1', 'VAR_IN_RUN','']
console.log('[Print in action running by script]:',process.env)
envKeys.forEach(key=>{
console.log(key,":",process.env[key])
})

0 comments on commit fe86899

Please sign in to comment.