-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
25 lines (25 loc) · 1.01 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
name: 'Reusable Workflow Context'
description: 'Extracts metadata of the reusable workflow it is used in'
branding:
icon: 'award'
color: 'green'
inputs:
path:
description: 'The path where the reusable workflow is located.'
required: true
outputs:
ref:
description: 'For a reusable workflow executing an action, this is the ref of the reusable workflow being executed.'
value: ${{ fromJSON(steps.context.outputs.json).ref }}
sha:
description: 'For a reusable workflow executing an action, this is the sha of the reusable workflow being executed.'
value: ${{ fromJSON(steps.context.outputs.json).sha }}
runs:
using: 'composite'
steps:
- id: context
env:
WORKFLOW_PATH: ${{ inputs.path }}
GITHUB_TOKEN: ${{ github.token }}
run: gh api repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID} | jq -c '.referenced_workflows // [] | map(select(.path | test(env.WORKFLOW_PATH))) | .[0] // {}' | xargs -0 -I {} echo "json={}" | tee -a $GITHUB_OUTPUT
shell: bash