-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (64 loc) · 1.92 KB
/
variables-and-context.yml
File metadata and controls
80 lines (64 loc) · 1.92 KB
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
# I am a workflow that demonstrates how to output the different context objects
name: Variables and Context
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'Person to greet'
# Default value if no value is explicitly provided
default: 'World'
# Input has to be provided for the workflow to run
required: true
env:
VAR1: myworkflowvar1
VAR2: myworkflowvar2
VAR3: myworkflowvar3
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
job1:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
#step/job output variables
job2:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.step1.outputs.step1value }}
output2: ${{ steps.step2.outputs.step2value }}
steps:
- name: Step 1
id: step1
# run: echo "::set-output name=step1value::hello"
run: echo "step1value=hello" >> $GITHUB_OUTPUT
- name: Step 2
id: step2
# run: echo "::set-output name=step2value::world"
run: echo "step2value=world" >> $GITHUB_OUTPUT
job3:
runs-on: ubuntu-latest
needs: job2
steps:
- run: echo ${{needs.job2.outputs.output1}} ${{needs.job2.outputs.output2}}
# access/set env variables
job4:
runs-on: ubuntu-latest
env:
VAR2: myjobvar2
VAR3: myjobvar3
steps:
- run: |
echo $VAR1
echo ${{env.VAR1}}
echo ""
echo $VAR2
echo $VAR3
env:
VAR3: mystepvar3