Skip to content

Commit

Permalink
add output
Browse files Browse the repository at this point in the history
  • Loading branch information
dkyrychenko committed Jul 4, 2024
1 parent 19a8e58 commit 233c30a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .github/workflows/reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ on:
required: true # should workflow fail if we are not getting this input
default: dist # if we won't receive an input value, we will use this default
type: string # input type, number, string, boolean, etc.
outputs:
my-result: # return value of the function
value: ${{ jobs.deploy.outputs.my-outcome }} # output value
description: Some output
required: true
type: string
#secrets:
#some-secret:
#required: false

jobs:
deploy:
outputs:
my-outcome: ${{ steps.set-result.outputs.my-step-result }} # output value
runs-on: ubuntu-latest
steps:
- name: Get build artifacts
Expand All @@ -19,4 +30,7 @@ jobs:
- name: List files
run: ls
- name: Deploy
run: echo "Deploying something..."
run: echo "Deploying something..."
- name: Set output
id: set-result
run: echo "::set-output name=my-step-result::success" # output value
9 changes: 9 additions & 0 deletions .github/workflows/use-reuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,21 @@ jobs:
with:
name: dist-files
path: dist

deploy:
needs: build
uses: ./.github/workflows/reusable.yml # Reusable workflow
with:
my-artifact-name: dist-files # function params, e.g. here - dist-files
#secrets:
#some-secret: ${{ secrets.SOME_SECRET }} # secret function params

print-deploy-result:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Output deploy result
run: echo "${{ needs.deploy.outputs.my-result }} # function return value
report:
needs: [lint, deploy] # first and last of the sequence (lint is parallel). Important for IF statement to work, otherwise report will run in parallel and won't do the trick
if: failure()
Expand Down

0 comments on commit 233c30a

Please sign in to comment.