Skip to content

Commit

Permalink
fix action_ref (composite action) (#2020)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
ChristopherHX and mergify[bot] committed Oct 3, 2023
1 parent 7c7d80e commit 976df8b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/runner/action_composite.go
Expand Up @@ -37,6 +37,9 @@ func evaluateCompositeInputAndEnv(ctx context.Context, parent *RunContext, step
env[envKey] = ee.Interpolate(ctx, input.Default)
}
}
gh := step.getGithubContext(ctx)
env["GITHUB_ACTION_REPOSITORY"] = gh.ActionRepository
env["GITHUB_ACTION_REF"] = gh.ActionRef

return env
}
Expand All @@ -53,11 +56,11 @@ func newCompositeRunContext(ctx context.Context, parent *RunContext, step action
Name: parent.Name,
JobName: parent.JobName,
Run: &model.Run{
JobID: "composite-job",
JobID: parent.Run.JobID,
Workflow: &model.Workflow{
Name: parent.Run.Workflow.Name,
Jobs: map[string]*model.Job{
"composite-job": {},
parent.Run.JobID: {},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/runner/run_context.go
Expand Up @@ -627,6 +627,8 @@ func (rc *RunContext) getGithubContext(ctx context.Context) *model.GithubContext
Token: rc.Config.Token,
Job: rc.Run.JobID,
ActionPath: rc.ActionPath,
ActionRepository: rc.Env["GITHUB_ACTION_REPOSITORY"],
ActionRef: rc.Env["GITHUB_ACTION_REF"],
RepositoryOwner: rc.Config.Env["GITHUB_REPOSITORY_OWNER"],
RetentionDays: rc.Config.Env["GITHUB_RETENTION_DAYS"],
RunnerPerflog: rc.Config.Env["RUNNER_PERFLOG"],
Expand Down
1 change: 1 addition & 0 deletions pkg/runner/runner_test.go
Expand Up @@ -237,6 +237,7 @@ func TestRunEvent(t *testing.T) {
{workdir, "uses-composite-with-error", "push", "Job 'failing-composite-action' failed", platforms, secrets},
{workdir, "uses-nested-composite", "push", "", platforms, secrets},
{workdir, "remote-action-composite-js-pre-with-defaults", "push", "", platforms, secrets},
{workdir, "remote-action-composite-action-ref", "push", "", platforms, secrets},
{workdir, "uses-workflow", "push", "", platforms, map[string]string{"secret": "keep_it_private"}},
{workdir, "uses-workflow", "pull_request", "", platforms, map[string]string{"secret": "keep_it_private"}},
{workdir, "uses-docker-url", "push", "", platforms, secrets},
Expand Down
@@ -0,0 +1,8 @@
name: remote-action-composite-action-ref
on: push

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: nektos/act-test-actions/composite-assert-action-ref-action@main

0 comments on commit 976df8b

Please sign in to comment.