Skip to content

Commit

Permalink
add pass var step
Browse files Browse the repository at this point in the history
modify script print var
  • Loading branch information
slow-groovin committed Oct 17, 2024
1 parent 6dc4566 commit 08c0cac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,24 @@ jobs:
run: |
cd environment
echo "VAR_IN_RUN=<var in run>" >> $GITHUB_ENV # set env variable in running
echo "[Print in step run]: ${{vars.VAR_IN_REPO}},${{secrets.SECRET_IN_REPO}},${{env.VAR_IN_JOB1}}, ${{env.VAR_IN_STEP1}}, ${{env.VAR_IN_RUN}} "
echo "[Print `${{}}`in step run]: ${{vars.VAR_IN_REPO}},${{secrets.SECRET_IN_REPO}},${{env.VAR_IN_JOB1}}, ${{env.VAR_IN_STEP1}}, ${{env.VAR_IN_RUN}}"
echo "[Print `$` in step run], $VAR_IN_REPO,$SECRET_IN_REPO, $VAR_IN_JOB1, $VAR_IN_STEP1, $VAR_IN_RUN"
node printVarsByActionRun.js
# console log result 👆👆:
# [Print in step run]: ,,<var in job1>, <var in step1>,
#
# [Print in step run]: <var in repo>,***,<var in job1>, <var in step1>,
# [Print in action running by script]:
# VAR_REPO : undefined
# SECRET_IN_REPO : undefined
# VAR_IN_JOB1 : <var in job1>
# VAR_IN_STEP1 : <var in step1>



- name: pass vars to script
run: |
cd environment
SECRET_IN_REPO=${{secrets.SECRET_IN_REPO}} node printVarsByActionRun.js
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions environment/printVarsByActionRun.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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)
const envKeys=['VAR_IN_REPO', 'SECRET_IN_REPO', 'VAR_IN_JOB1', 'VAR_IN_STEP1', 'VAR_IN_RUN']
console.log('[script Print in action]:')
envKeys.forEach(key=>{
console.log(key,":",process.env[key])
})
6 changes: 3 additions & 3 deletions environment/printVarsByDockerfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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)
const envKeys=['VAR_IN_REPO', 'SECRET_IN_REPO', 'VAR_IN_JOB1', 'VAR_IN_STEP1', 'VAR_IN_RUN','BUILD_ARG1','SECRETS1','SECRET_ENV_1']
console.log('[script Print in Dockerfile]:')
envKeys.forEach(key=>{
console.log(key,":",process.env[key])
})
})

0 comments on commit 08c0cac

Please sign in to comment.