Skip to content

Commit 976df8b

Browse files
fix action_ref (composite action) (#2020)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 7c7d80e commit 976df8b

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

pkg/runner/action_composite.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ func evaluateCompositeInputAndEnv(ctx context.Context, parent *RunContext, step
3737
env[envKey] = ee.Interpolate(ctx, input.Default)
3838
}
3939
}
40+
gh := step.getGithubContext(ctx)
41+
env["GITHUB_ACTION_REPOSITORY"] = gh.ActionRepository
42+
env["GITHUB_ACTION_REF"] = gh.ActionRef
4043

4144
return env
4245
}
@@ -53,11 +56,11 @@ func newCompositeRunContext(ctx context.Context, parent *RunContext, step action
5356
Name: parent.Name,
5457
JobName: parent.JobName,
5558
Run: &model.Run{
56-
JobID: "composite-job",
59+
JobID: parent.Run.JobID,
5760
Workflow: &model.Workflow{
5861
Name: parent.Run.Workflow.Name,
5962
Jobs: map[string]*model.Job{
60-
"composite-job": {},
63+
parent.Run.JobID: {},
6164
},
6265
},
6366
},

pkg/runner/run_context.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
627627
Token: rc.Config.Token,
628628
Job: rc.Run.JobID,
629629
ActionPath: rc.ActionPath,
630+
ActionRepository: rc.Env["GITHUB_ACTION_REPOSITORY"],
631+
ActionRef: rc.Env["GITHUB_ACTION_REF"],
630632
RepositoryOwner: rc.Config.Env["GITHUB_REPOSITORY_OWNER"],
631633
RetentionDays: rc.Config.Env["GITHUB_RETENTION_DAYS"],
632634
RunnerPerflog: rc.Config.Env["RUNNER_PERFLOG"],

pkg/runner/runner_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ func TestRunEvent(t *testing.T) {
237237
{workdir, "uses-composite-with-error", "push", "Job 'failing-composite-action' failed", platforms, secrets},
238238
{workdir, "uses-nested-composite", "push", "", platforms, secrets},
239239
{workdir, "remote-action-composite-js-pre-with-defaults", "push", "", platforms, secrets},
240+
{workdir, "remote-action-composite-action-ref", "push", "", platforms, secrets},
240241
{workdir, "uses-workflow", "push", "", platforms, map[string]string{"secret": "keep_it_private"}},
241242
{workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}},
242243
{workdir, "uses-docker-url", "push", "", platforms, secrets},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: remote-action-composite-action-ref
2+
on: push
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: nektos/act-test-actions/composite-assert-action-ref-action@main

0 commit comments

Comments
 (0)