From 0f21d1cf513567ebf690664d7d553478a9a12b21 Mon Sep 17 00:00:00 2001 From: watteja Date: Tue, 25 Feb 2025 13:16:09 +0100 Subject: [PATCH] Correct information about env context availability To the best of my knowledge, the removed information was not correct. I have tried myself to access environment variable with `github.env`, and it doesn't work. I then went online only to find advice such as this one, which worked for me and which I changed in the materials: https://stackoverflow.com/questions/73558652/github-actions-how-to-use-environment-variable-at-job-level --- src/content/11/en/part11d.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/content/11/en/part11d.md b/src/content/11/en/part11d.md index 55914597a07..a137ce53999 100644 --- a/src/content/11/en/part11d.md +++ b/src/content/11/en/part11d.md @@ -292,6 +292,8 @@ env: jobs: job1: # rest of the job + outputs: + condition: ${{ env.CONDITION }} steps: - if: ${{ env.CONDITION == 'true' }} run: echo 'this step is executed' @@ -300,8 +302,9 @@ jobs: run: echo 'this step will not be executed' job2: - # this job will be dependent on the above env.CONDITION, note the `github.` prefix which seem to be required while referencing the variable on the job level, but not the step level - if: ${{ github.env.CONDITION == 'true' }} + # as env variables are not available at job level, we can use the output of job1 instead + needs: [job1] + if: ${{ needs.job1.outputs.condition == 'true' }} # rest of the job ```