Skip to content

Commit 2614b3e

Browse files
KnisterPeterChristopherHXmergify[bot]
authored
fix: keep path to event json file in composite actions (#1428)
* fix: keep path to event json file in composite actions The event.json paths need to be copied over, since it the GithubContext is recreated from the composite RC. And that does read some value for the event file if available. * test: add test case * test: paste the test correctly and revert a line Co-authored-by: ChristopherHX <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 1b554ae commit 2614b3e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: pkg/runner/action_composite.go

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func newCompositeRunContext(ctx context.Context, parent *RunContext, step action
6969
Masks: parent.Masks,
7070
ExtraPath: parent.ExtraPath,
7171
Parent: parent,
72+
EventJSON: parent.EventJSON,
7273
}
7374

7475
return compositerc

Diff for: pkg/runner/testdata/pull-request/main.yaml

+17-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ jobs:
55
build:
66
runs-on: ubuntu-latest
77
steps:
8-
- run: echo '${{github.ref}}'
8+
# test refs from event.json
9+
- run: echo '${{github.ref}}'
910
- run: echo '${{github.head_ref}}' | grep sample-head-ref
1011
- run: echo '${{github.base_ref}}' | grep sample-base-ref
12+
# test main/composite context equality with data from event.json
13+
- run: |
14+
runs:
15+
using: composite
16+
steps:
17+
- run: |
18+
echo WORKFLOW_GITHUB_CONTEXT="$WORKFLOW_GITHUB_CONTEXT"
19+
echo COMPOSITE_GITHUB_CONTEXT="$COMPOSITE_GITHUB_CONTEXT"
20+
[[ "$WORKFLOW_GITHUB_CONTEXT" = "$COMPOSITE_GITHUB_CONTEXT" ]]
21+
env:
22+
WORKFLOW_GITHUB_CONTEXT: ${{ tojson(tojson(github.event)) }}
23+
COMPOSITE_GITHUB_CONTEXT: ${{ '${{tojson(github.event)}}' }}
24+
shell: bash
25+
shell: cp {0} action.yml
26+
- uses: ./

0 commit comments

Comments
 (0)