Skip to content

Commit e236259

Browse files
committed
Support nested composite actions
To reference metadata about composite actions, GitHub Actions provides the `github.action_` context, including `github.action_path`, `github.action_ref`, and `github.action_repository`. GitHub Actions supports nested composite actions with a recursion limit of 9 (9 nested composite actions). Unfortunately `github.action_` values are not propagated correctly when running nested composite actions. This is a bug in the GitHub Actions runner. The suggested workaround is to use inputs to set the correct values. This commit will implement the suggested workaround. https://docs.github.com/en/actions/creating-actions/creating-a-composite-action https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context actions/runner#2473 (comment) pypa#299
1 parent 15c56db commit e236259

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

action.yml

+29-3
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,27 @@ inputs:
8787
Only works with PyPI and TestPyPI via Trusted Publishing.
8888
required: false
8989
default: 'true'
90+
action_path:
91+
description: >-
92+
[EXPERIMENTAL]
93+
Set action path to work around bug in nested composite actions
94+
https://github.com/actions/runner/issues/2473
95+
required: false
96+
default: ${{ github.action_path }}
97+
action_repository:
98+
description: >-
99+
[EXPERIMENTAL]
100+
Set action repository to work around bug in nested composite actions
101+
https://github.com/actions/runner/issues/2473
102+
required: false
103+
default: ${{ github.action_repository }}
104+
action_ref:
105+
description: >-
106+
[EXPERIMENTAL]
107+
Set action ref to work around bug in nested composite actions
108+
https://github.com/actions/runner/issues/2473
109+
required: false
110+
default: ${{ github.action_ref }}
90111
branding:
91112
color: yellow
92113
icon: upload-cloud
@@ -116,17 +137,21 @@ runs:
116137
run: |
117138
# Set repo and ref from which to run Docker container action
118139
# to handle cases in which `github.action_` context is not set
140+
# or set properly for nested composite actions
119141
# https://github.com/actions/runner/issues/2473
142+
ACTION_PATH=${{ env.ACTION_PATH || '.' }}
120143
REF=${{ env.ACTION_REF || env.PR_REF || github.ref_name }}
121144
REPO=${{ env.ACTION_REPO || env.PR_REPO || github.repository }}
122145
REPO_ID=${{ env.PR_REPO_ID || github.repository_id }}
146+
echo "action-path=$ACTION_PATH" >>"$GITHUB_OUTPUT"
123147
echo "ref=$REF" >>"$GITHUB_OUTPUT"
124148
echo "repo=$REPO" >>"$GITHUB_OUTPUT"
125149
echo "repo-id=$REPO_ID" >>"$GITHUB_OUTPUT"
126150
shell: bash
127151
env:
128-
ACTION_REF: ${{ github.action_ref }}
129-
ACTION_REPO: ${{ github.action_repository }}
152+
ACTION_PATH: ${{ inputs.action_path }}
153+
ACTION_REF: ${{ inputs.action_ref }}
154+
ACTION_REPO: ${{ inputs.action_repository }}
130155
PR_REF: ${{ github.event.pull_request.head.ref }}
131156
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
132157
PR_REPO_ID: ${{ github.event.pull_request.base.repo.id }}
@@ -149,8 +174,9 @@ runs:
149174
steps.pre-installed-python.outputs.python-path == ''
150175
&& steps.new-python.outputs.python-path
151176
|| steps.pre-installed-python.outputs.python-path
152-
}} '${{ github.action_path }}/create-docker-action.py'
177+
}} '${{ env.ACTION_PATH }}/create-docker-action.py'
153178
env:
179+
ACTION_PATH: ${{ steps.set-repo-and-ref.outputs.action-path }}
154180
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
155181
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
156182
REPO_ID: ${{ steps.set-repo-and-ref.outputs.repo-id }}

0 commit comments

Comments
 (0)