Hot Posts

hot/hot-posts

Pass a variable between jobs in Github Action


To set the output of a step in a Github Actions workflow and use it in a subsequent job, you can use the run command to save the output as an environment variable. Here's an example in YAML syntax:
yaml
jobs:
job1: runs-on: ubuntu-latest steps: - name: Get output value run: echo "::set-output name=value::42" job2: runs-on: ubuntu-latest needs: job1 steps: - name: Use output value run: echo "The value is ${{ steps.job1.outputs.value }}"

In the above example, job1 sets an output named value to 42. The second job, job2, depends on job1 and accesses the output using steps.job1.outputs.value.

Post a Comment

0 Comments