10 - Environment Workflow #1021
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
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" |