From d46758e186d0368572da8dc2cac10fe8ef787840 Mon Sep 17 00:00:00 2001 From: GuillaumeFalourd Date: Tue, 12 Dec 2023 08:54:32 -0300 Subject: [PATCH] add many-outputs python workflow --- .github/workflows/71-many-outputs-python.yml | 27 ++++++++++++++++++++ output_function.py | 9 +++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/71-many-outputs-python.yml create mode 100644 output_function.py diff --git a/.github/workflows/71-many-outputs-python.yml b/.github/workflows/71-many-outputs-python.yml new file mode 100644 index 0000000000..70fbfeb196 --- /dev/null +++ b/.github/workflows/71-many-outputs-python.yml @@ -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 }} \ No newline at end of file diff --git a/output_function.py b/output_function.py new file mode 100644 index 0000000000..933a0f6037 --- /dev/null +++ b/output_function.py @@ -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") \ No newline at end of file