-
Notifications
You must be signed in to change notification settings - Fork 102
81 lines (70 loc) · 2.16 KB
/
10-environment-workflow.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: 10 - Environment Workflow
on:
schedule:
- cron: "0 8 * * MON-FRI" # Runs at 08:00 UTC
workflow_dispatch:
env:
WORKFLOW_VARIABLE: WORKFLOW
jobs:
job1:
runs-on: ubuntu-latest
env:
JOB_VARIABLE: JOB
steps:
- name: Run Commands with various variables
if: ${{ env.WORKFLOW_VARIABLE == 'WORKFLOW' }}
env:
STEP_VARIABLE: STEP
run: |
echo "Hello World"
echo "This is the $WORKFLOW_VARIABLE environment variable"
echo "This is the $JOB_VARIABLE environment variable"
echo "This is the $STEP_VARIABLE environment variable"
job2:
runs-on: ubuntu-latest
env:
JOB_VARIABLE: JOB2
steps:
- name: Run Commands with WORKFLOW variable
if: ${{ env.WORKFLOW_VARIABLE != 'WORKFLOW' }}
run: |
echo "Hello World"
echo "This is the $WORKFLOW_VARIABLE environment"
echo "This is a step variable: $STEP_VARIABLE"
env:
STEP_VARIABLE: my step variable value that could also be a secret
- name: Run Commands with JOB variable
if: ${{ env.JOB_VARIABLE == 'JOB2' }}
run: |
echo "Hello World"
echo "This is the $JOB_VARIABLE environment"
echo "My name is $FIRST_STEP_VARIABLE $second_step_variable"
env:
FIRST_STEP_VARIABLE: Guillaume
second_step_variable: Falourd
job3:
runs-on: ubuntu-latest
steps:
- name: Set the value
id: step_1
run: |
echo "action_state=yellow" >> $GITHUB_ENV
- name: Use the value
id: step_2
run: |
echo "${{ env.action_state }}" # This will output 'yellow'
job4:
runs-on: ubuntu-latest
environment: test
steps:
- name: Show repo env secret
run: |
echo ${{ secrets.REPO_ENV_SECRET }}
# Deprecated with https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
# job3:
# runs-on: ubuntu-latest
# steps:
# - name: step-1
# run: echo "::set-env name=IP_ADDRESS::$(curl -s ifconfig.me)"
# - name: step-2
# run: echo "$IP_ADDRESS"