Last active
January 14, 2023 02:41
-
-
Save parjun8840/a5a5891f7a41675e871e146985c80fd5 to your computer and use it in GitHub Desktop.
ENV variable code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.github/workflows/env_var.yaml | |
name: accessing information inside worfkflow | |
on: [push] | |
env: | |
WF_LEVEL_ENV: available for all jobs in this workflow | |
jobs: | |
echo-information: | |
env: | |
JOB_LEVEL_ENV: available for this specific job only | |
DAY_OF_WEEK: Sunday | |
runs-on: ubuntu-latest | |
steps: | |
- name: default environment variables availiable to the entire workflow | |
run: | | |
echo "Home: ${HOME}" | |
echo "GITHUB_WORKFLOW: ${GITHUB_WORKFLOW}" | |
echo "GITHUB_ACTIONS: ${GITHUB_ACTIONS}" | |
echo "GITHUB_ACTOR: ${GITHUB_ACTOR}" | |
echo "GITHUB_REPOSITORY: ${GITHUB_REPOSITORY}" | |
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" | |
echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}" | |
echo "GITHUB_SHA: ${GITHUB_SHA}" | |
echo "GITHUB_REF: ${GITHUB_REF}" | |
- name: print WF_LEVEL_ENV | |
run: | | |
echo "This is Workflow level variable- ${WF_LEVEL_ENV}" | |
echo "This is Workflow level variable accessing using env context- ${{ env.WF_LEVEL_ENV }}" | |
- name: print JOB_LEVEL_ENV | |
run: echo "This is Job level variable- ${JOB_LEVEL_ENV}" | |
- name: print STEP_LEVEL_ENV | |
env: | |
STEP_LEVEL_ENV: available for this specific step only | |
run: echo "This is Step level variable- ${STEP_LEVEL_ENV}" | |
- name: "Say Hello" | |
if: env.DAY_OF_WEEK == 'Sunday' | |
run: echo "${GREETING} ${GITHUB_ACTOR}!! Have a great ${DAY_OF_WEEK}" | |
env: | |
GREETING: Hello | |
- name: print REPO_ENV_VAR | |
run: echo "This is REPO level varirable- ${{ vars.REPO_ENV_VAR }}" | |
- name: print scret- MY_FIRST_SECRET | |
run: echo "This is secret- ${{ secrets.MY_FIRST_SECRET }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updating secret example