Skip to content

Commit

Permalink
Create variables-and-context.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
rajurh authored Oct 10, 2022
1 parent 9613921 commit 205605f
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/variables-and-context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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"

- name: Step 2
id: step2
run: echo "::set-output name=step2value::world"

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

0 comments on commit 205605f

Please sign in to comment.