Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend github context with host-workspace #2517

Merged

Conversation

nikola-jokic
Copy link
Contributor

We encountered an issue where step host was not used when evaluating user inputs.
The PR #1762 fixed this problem, but it introduced another problem for hash files.

hashFiles operates on the host, regardless of whether you are running inside the container or not.

Since inputs are translated based on the step host, we lose the ability to know how to translate back from the container path to the host path.

This change aims to add another context variable to the runner context named host-workspace that will be set to the runner host workspace regardless of whether the action is executed inside the container or not.
Example of the composite action:

name: "test"
runs:
  using: "composite"
  steps:
  - run: |
      echo "${{github.action_path}}"
      echo "${{github.workspace}}" 
      echo "${{github.event_path}}"
    shell: bash
    name: "Just echo"
  - run: echo ${{ hashFiles('**/*.lock')}}
    shell: bash
    name: "test"

Repro of this issue with StepHost evaluation and hash files:
image

After applying this change:
image

Related to #716

@abhijeetdhoke
Copy link

@nikola-jokic could you please help us to fix this issue we are stuck from last week on same stage, I dont have resolution for this.

@nikola-jokic nikola-jokic force-pushed the nikola-jokic/host-workspace-ctx branch from 88a37b1 to 9a03f27 Compare June 27, 2023 08:50
@nikola-jokic nikola-jokic changed the title Extend runner context with host-workspace Extend runner context with host-work-directory Jun 28, 2023
@nikola-jokic nikola-jokic changed the title Extend runner context with host-work-directory Extend github context with host-workspace Jun 29, 2023
Copy link
Contributor

@fhammerl fhammerl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikola-jokic nikola-jokic merged commit c05e674 into actions:main Jun 29, 2023
@nikola-jokic nikola-jokic deleted the nikola-jokic/host-workspace-ctx branch June 29, 2023 10:12
ashb pushed a commit to ashb/runner that referenced this pull request Jun 30, 2023
* hash files translation works with host context translated

* Change file encoding to utf8 for PipelineTemplateConstants.cs

* infer the feature flag on hash files based on the existence of the context

* encoded utf8 with bom

* rename host-workspace to host-work-directory and feature flag the new context var

* Added comment to explain ignore host work directory resolution

Co-authored-by: fhammerl <[email protected]>

* trigger pipeline

* Move to the github host-workspace context instead of the runner host-work-directory

* remove unused imports

---------

Co-authored-by: fhammerl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants