[PR #1958] [MERGED] feat: support interpolation in <job>.container.options #2209

Closed
opened 2026-03-01 21:54:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/1958
Author: @eliandoran
Created: 8/9/2023
Status: Merged
Merged: 9/12/2023
Merged by: @cplee

Base: masterHead: feat/variable_interpolation_in_container_options


📝 Commits (1)

  • 6279709 feat: support interpolation in <job>.container.options

📊 Changes

1 file changed (+4 additions, -4 deletions)

View changed files

📝 pkg/runner/run_context.go (+4 -4)

📄 Description

Desired functionality

Seems that act does not support variable interpolation in the --device option:

jobs:
  build:
    container:
      options: -uroot --device=${{ inputs.device }}

Results in:

Error: Cannot process container options: '-uroot --device=${{ inputs.device }}': '${{ is not an absolute path'

Seems that variable interpolation is not enabled anywhere in the options field, since it's doing the same for the -u flag:

-u${{inputs.user }}

Results in:

Error: failed to start container: Error response from daemon: unable to find user ${{inputs.user}}: no matching entries in passwd file

These are supported in the live GitHub Actions runner.

Approach

Adapted options method in run_context.go to be in the same style as containerImage which already has support for variable interpolation:

func (rc *RunContext) containerImage(ctx context.Context) string {
	job := rc.Run.Job()

	c := job.Container()
	if c != nil {
		return rc.ExprEval.Interpolate(ctx, c.Image)
	}

	return ""
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/1958 **Author:** [@eliandoran](https://github.com/eliandoran) **Created:** 8/9/2023 **Status:** ✅ Merged **Merged:** 9/12/2023 **Merged by:** [@cplee](https://github.com/cplee) **Base:** `master` ← **Head:** `feat/variable_interpolation_in_container_options` --- ### 📝 Commits (1) - [`6279709`](https://github.com/nektos/act/commit/6279709599fb5e6311c0030193046a99a6062dbf) feat: support interpolation in `<job>.container.options` ### 📊 Changes **1 file changed** (+4 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `pkg/runner/run_context.go` (+4 -4) </details> ### 📄 Description ### Desired functionality Seems that act does not support variable interpolation in the `--device` option: ```yaml jobs: build: container: options: -uroot --device=${{ inputs.device }} ``` Results in: ``` Error: Cannot process container options: '-uroot --device=${{ inputs.device }}': '${{ is not an absolute path' ``` Seems that variable interpolation is not enabled anywhere in the options field, since it's doing the same for the `-u` flag: ``` -u${{inputs.user }} ``` Results in: ``` Error: failed to start container: Error response from daemon: unable to find user ${{inputs.user}}: no matching entries in passwd file ``` These are supported in the live GitHub Actions runner. ### Approach Adapted `options` method in `run_context.go` to be in the same style as `containerImage` which already has support for variable interpolation: ```go func (rc *RunContext) containerImage(ctx context.Context) string { job := rc.Run.Job() c := job.Container() if c != nil { return rc.ExprEval.Interpolate(ctx, c.Image) } return "" } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:54:28 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#2209
No description provided.