-
Notifications
You must be signed in to change notification settings - Fork 76
57 lines (54 loc) · 1.72 KB
/
08-variables.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: 08 - Using Variables
on:
push:
workflow_dispatch:
env:
WORKFLOW_VAR: 'I am a workflow env var'
OVERWRITTEN: 'I will be overwritten'
UNDEFINED_VAR_WITH_DEFAULT: ${{ vars.UNDEFINED_VAR || 'default value' }}
jobs:
echo:
runs-on: ubuntu-latest
env:
JOB_VAR: 'I am a job env var'
OVERWRITTEN: 'I have been overwritten at the job level'
steps:
- name: Print Env Variables
env:
STEP_VAR: 'I am a step env var'
step_var2: 'I am another step env var'
run: |
echo "Step env var: ${{ env.STEP_VAR }}"
echo "Step env var 2: $step_var2"
echo "Job env var: ${{ env.JOB_VAR }}"
echo "Workflow env var: ${{ env.WORKFLOW_VAR }}"
echo "Overwritten: ${{ env.OVERWRITTEN }}"
- name: Overwrite job variable
env:
OVERWRITTEN: 'I have been overwritten at the step level'
run: |
echo "Step env var: ${{ env.OVERWRITTEN }}"
echo2:
runs-on: ubuntu-latest
steps:
- name: Print Variables
run: |
echo "Org var: ${{ vars.ORG_VAR }}"
echo "Org overwritten var: ${{ vars.OVERWRITTEN_VAR }}"
echo "Repo var: ${{ vars.REPOSITORY_VAR }}"
echo-prod:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Print Prod Variables
run: |
echo "Org var: ${{ vars.ORG_VAR }}"
echo "Org overwritten var: ${{ vars.OVERWRITTEN_VAR }}"
echo "Repo var: ${{ vars.REPOSITORY_VAR }}"
echo "Environment var: ${{ vars.TARGET_VAR }}"
echo-undefined:
runs-on: ubuntu-latest
steps:
- name: Print Undefined Variables
run: |
echo "Org var: ${{ env.UNDEFINED_VAR_WITH_DEFAULT }}"