Skip to content

Instantly share code, notes, and snippets.

@vikas-bisht16
Created March 31, 2023 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vikas-bisht16/868b9bf991c8245041b0fee46fa94086 to your computer and use it in GitHub Desktop.
Save vikas-bisht16/868b9bf991c8245041b0fee46fa94086 to your computer and use it in GitHub Desktop.
name: Share data between jobs
on: [push]
jobs:
job_1:
name: Add 3 and 7
runs-on: actions_runner_dev
steps:
- shell: bash
run: |
expr 3 + 7 > math-homework.txt
- name: Upload math result for job 1
uses: actions/upload-artifact@v3
with:
name: homework
path: math-homework.txt
job_2:
name: Multiply by 9
needs: job_1
runs-on: actions_runner_dev
steps:
- name: Download math result for job 1
uses: actions/download-artifact@v3
with:
name: homework
- shell: bash
run: |
value=`cat math-homework.txt`
expr $value \* 9 > math-homework.txt
- name: Upload math result for job 2
uses: actions/upload-artifact@v3
with:
name: homework
path: math-homework.txt
job_3:
name: Display results
needs: job_2
runs-on: actions_runner_dev
steps:
- name: Download math result for job 2
uses: actions/download-artifact@v3
with:
name: homework
- name: Print the final result
shell: bash
run: |
value=`cat math-homework.txt`
echo The result is $value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment