Skip to content

Pre-execution script before the workflow starts #226

@cllouud

Description

@cllouud

We use Kubernetes modes. Runner pod creates workflow pod in the same namespace.

The workflow pod mounts NPU resources. Occasionally, workflow pod starts to execute Github Action workflow before NPU resources are fully ready, causing GitHub Actions workflow to fail.

One solution: repo maintainers update workflow files to check NPU resources. But it is not convenient for users.

So we modified packages/k8s/src/hooks/run-script-step.ts to inject a pre-execution script (/check-npu/check.sh) before running the workflow

try {
  await execPodStep(
    ['/bin/bash', '-el', `/check-npu/check.sh`],
    state.jobPod,
    JOB_CONTAINER_NAME
  );
} catch (err) {
  core.debug(`execPodStep failed: ${JSON.stringify(err)}`);
  const message = (err as any)?.response?.body?.message || err;
  throw new Error(`failed to run script step: ${message}`);
}

This resolves the problem but increases maintenance overhead since we now maintain a custom code fork.

Instead of hardcoding a script path, could you add an ​​optional configuration​​ to execute a user-specified script (e.g., from a predefined directory) before the workflow starts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions