Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carlos-a-g-h/629c473c7dcafb1ac51e56ed823af46d to your computer and use it in GitHub Desktop.
Save carlos-a-g-h/629c473c7dcafb1ac51e56ed823af46d to your computer and use it in GitHub Desktop.
GH Workflows: Sharing step output variables across jobs using artifacts
name: "test"
on:
[workflow_dispatch]
jobs:
first:
name: First Job
runs-on: ubuntu-latest
steps:
- name: Get Date
id: step_date
run: |
echo "TODAY=$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_OUTPUT
- name: Print date
run: |
echo "TODAY IS ${{ steps.step_date.outputs.TODAY }}"
echo "" > NOTES.txt
echo "DATE_TODAY=${{ steps.step_date.outputs.TODAY }}" >> NOTES.txt
echo "HELLO=WORLD" >> NOTES.txt
ls NOTES.txt
cat NOTES.txt
- name: Upload Notes
uses: actions/upload-artifact@v3
with:
name: "NOTES"
if-no-files-found: error
path: "NOTES.txt"
second:
name: Second Job
needs: [first]
runs-on: ubuntu-latest
steps:
- name: Download Notes
uses: actions/download-artifact@v3
with:
name: "NOTES"
- name: Check notes and save content
id: step_notes
run: |
echo "contents of the NOTES.txt file"
cat NOTES.txt
cat NOTES.txt >> $GITHUB_OUTPUT
- name: Print Notes contents
run: |
echo "TODAY IS ${{ steps.step_notes.outputs.DATE_TODAY }}"
echo "HI THERE ${{ steps.step_notes.outputs.HELLO }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment