Fix failed to create container if the runner works in root dir #67

Merged
Zettat123 merged 2 commits from bugfix/issue-#56 into main 2023-03-23 01:41:23 +00:00
Zettat123 commented 2023-03-22 07:14:09 +00:00 (Migrated from gitea.com)

Fix #56

This PR uses the preset.Repository as a part of the workdir and use filepath.FromSlash to convert the slash characters.

Fix #56 This PR uses the `preset.Repository` as a part of the workdir and use `filepath.FromSlash` to convert the slash characters.
ChristopherHX (Migrated from gitea.com) reviewed 2023-03-22 08:28:01 +00:00
@@ -0,0 +214,4 @@
config := &runner.Config{
// On Linux, Workdir will be like "/<owner>/<repo>"
// On Windows, Workdir will be like "\<owner>\<repo>"
Workdir: filepath.FromSlash(string(filepath.Separator) + preset.Repository),
ChristopherHX (Migrated from gitea.com) commented 2023-03-22 08:28:01 +00:00

I think + string(filepath.Separator) at the end of the string is important, it were missing and local actions stopped working.

Have you tested an action with uses: ./ or uses: ./myaction/sub?

// On Linux, Workdir will be like "/<owner>/<repo>/"

Otherwise act has to be patched to resolve local actions without a / or \ at the end correctly.

I think `+ string(filepath.Separator)` at the end of the string is important, it were missing and local actions stopped working. Have you tested an action with `uses: ./` or `uses: ./myaction/sub`? `// On Linux, Workdir will be like "/<owner>/<repo>/"` Otherwise act has to be patched to resolve local actions without a / or \ at the end correctly.
Zettat123 (Migrated from gitea.com) reviewed 2023-03-22 08:34:30 +00:00
@@ -0,0 +214,4 @@
config := &runner.Config{
// On Linux, Workdir will be like "/<owner>/<repo>"
// On Windows, Workdir will be like "\<owner>\<repo>"
Workdir: filepath.FromSlash(string(filepath.Separator) + preset.Repository),
Zettat123 (Migrated from gitea.com) commented 2023-03-22 08:34:30 +00:00

Sorry, I haven't tested local actions and I will make one then test it. Thanks for your review!

Sorry, I haven't tested local actions and I will make one then test it. Thanks for your review!
Zettat123 commented 2023-03-22 10:47:18 +00:00 (Migrated from gitea.com)

@ChristopherHX Hi, I just tested a local action and I found it works well. In my test, I didn't append the string(filepath.Separator) at the end of Workdir so the Workdir is /<owner>/<repo>

My directory structure is:

├── actions
│   └── my-action
│       ├── action.yml
│       └── index.js
├── .gitea
│   └── workflows
│       └── my-workflow.yml
└── README.md

and the my-workflow.yml is:

name: 'My Workflow'
on: [push]
jobs:
  my-job:
    runs-on: ubuntu-latest
    steps:
      - uses: https://github.com/actions/checkout@v3

      - name: 'My Step'
        uses: './actions/my-action'

@ChristopherHX Hi, I just tested a local action and I found it works well. In my test, I didn't append the `string(filepath.Separator)` at the end of `Workdir` so the `Workdir` is `/<owner>/<repo>` My directory structure is: ``` ├── actions │ └── my-action │ ├── action.yml │ └── index.js ├── .gitea │ └── workflows │ └── my-workflow.yml └── README.md ``` and the `my-workflow.yml` is: ``` yml name: 'My Workflow' on: [push] jobs: my-job: runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v3 - name: 'My Step' uses: './actions/my-action' ```
ChristopherHX commented 2023-03-22 11:24:04 +00:00 (Migrated from gitea.com)

Seems like you are right, there is no such problem on linux.

Seems like you are right, there is no such problem on linux.
wolfogre (Migrated from gitea.com) approved these changes 2023-03-23 01:40:30 +00:00
Sign in to join this conversation.