From c85eb0e6477d394da5115b530c9deab9b4ae0247 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Thu, 14 Aug 2025 11:21:51 +0200 Subject: [PATCH] fix: use a unique random name to derive network and volumes for a job When a reusable workflow is called twice in the same workflow in parallel, it may require a dedicated network to run (for instance if it spawns services) and will always require unique volumes to mount the workdir and the env. There really is no way to guarantee a unique name derived from the job name etc. Instead, a random name is set and used as a base for both the internal volumes and the dedicated network (if any). --- act/runner/run_context.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/act/runner/run_context.go b/act/runner/run_context.go index a1db2867..84c03188 100644 --- a/act/runner/run_context.go +++ b/act/runner/run_context.go @@ -126,11 +126,13 @@ func (rc *RunContext) getInternalVolumeNames(ctx context.Context) []string { } func (rc *RunContext) getInternalVolumeWorkdir(ctx context.Context) string { - return rc.jobContainerName() + rc.ensureRandomName(ctx) + return rc.randomName } func (rc *RunContext) getInternalVolumeEnv(ctx context.Context) string { - return fmt.Sprintf("%s-env", rc.jobContainerName()) + rc.ensureRandomName(ctx) + return fmt.Sprintf("%s-env", rc.randomName) } // Returns the binds and mounts for the container, resolving paths as appopriate @@ -423,9 +425,10 @@ func (rc *RunContext) getNetworkName(ctx context.Context) string { func (rc *RunContext) ensureNetworkName(ctx context.Context) { if rc.networkName == "" { + rc.ensureRandomName(ctx) rc.networkName = string(rc.Config.ContainerNetworkMode) if len(rc.Run.Job().Services) > 0 || rc.networkName == "" { - rc.networkName = fmt.Sprintf("%s-%s-network", rc.jobContainerName(), rc.Run.JobID) + rc.networkName = fmt.Sprintf("WORKFLOW-%s", rc.randomName) rc.networkCreated = true } }