Skip to content

Commit

Permalink
add many-outputs python workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeFalourd committed Dec 12, 2023
1 parent 62a9754 commit d46758e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/71-many-outputs-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 71 - Many Outputs Python

on:
workflow_dispatch:

jobs:
python-script:
runs-on: ubuntu-latest
outputs:
test1: ${{ steps.script.outputs.TEST1 }}
test2: ${{ steps.script.outputs.TEST2 }}
test3: ${{ steps.script.outputs.TEST3 }}
steps:
- uses: actions/checkout@v4
- name: Execute Python script
id: script
run: python output_function.py

job2:
runs-on: ubuntu-latest
needs: python-script
steps:
- name: Print outputs
run: |
echo ${{ needs.python-script.outputs.test1 }}
echo ${{ needs.python-script.outputs.test2 }}
echo ${{ needs.python-script.outputs.test3 }}
9 changes: 9 additions & 0 deletions output_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import os

def save_output(name: str, value: str):
with open(os.getenv('GITHUB_OUTPUT'), "a") as output_file:
output_file.write(f"{name}={value}")

save_output("TEST1", "VALUE1")
save_output("TEST2", "VALUE2")
save_output("TEST3", "VALUE3")

0 comments on commit d46758e

Please sign in to comment.