Repository: nektos/act (language: go)

Issue:
unable to find git repo
### Discussed in https://github.com/nektos/act/discussions/1545

<div type='discussions-op-text'>

<sup>Originally posted by **tornado404** January  4, 2023</sup>
# error
I got a error as following
```
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
[pushImage/bimg] [DEBUG] evaluating expression 'always()'
[pushImage/bimg] [DEBUG] expression 'always()' evaluated to 'true'
[pushImage/bimg] ⭐ Run Pre Get tag info
[pushImage/bimg] [DEBUG] Writing entry to tarball workflow/outputcmd.txt len:0
[pushImage/bimg] [DEBUG] Writing entry to tarball workflow/statecmd.txt len:0
[pushImage/bimg] [DEBUG] Writing entry to tarball workflow/pathcmd.txt len:0
[pushImage/bimg] [DEBUG] Extracting content to '/var/run/act'
[pushImage/bimg] [DEBUG] run pre step for 'Get tag info'
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
[pushImage/bimg]   ✅  Success - Pre Get tag info
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
[pushImage/bimg]   ☁  git clone 'https://github.com/pr-mpt/actions-commit-hash' # ref=v2
[pushImage/bimg] [DEBUG]   cloning https://github.com/pr-mpt/actions-commit-hash to /root/.cache/act/pr-mpt-actions-commit-hash@v2
[pushImage/bimg] Unable to resolve v2: unsupported object type
[pushImage/bimg] Unable to resolve v2: unsupported object type
[pushImage/bimg] [DEBUG] skipping post step for 'Build and push pfs-csi-plugin'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'Build and push ***-server'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'Login to DockerHub'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'get commit hash'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'Get tag info'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'Uploading assets'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'Checkout code'; step was not executed
[pushImage/bimg] [DEBUG] skipping post step for 'Install go'; step was not executed
[pushImage/bimg] [DEBUG] Removed container: cddf11fec1344b5aa6bddddcafaac4eb4b86d4534b045e13f7ca88039a742524
[pushImage/bimg] [DEBUG]   🐳  docker volume rm act-pushImage-bimg
[pushImage/bimg] [DEBUG]   🐳  docker volume rm act-pushImage-bimg-env
[pushImage/bimg] 🏁  Job succeeded
[pushImage/bimg] unable to get git repo: unable to find git repo
[pushImage/bimg] unable to get git ref: unable to find git repo
[pushImage/bimg] unable to get git revision: unable to find git repo
Error: unsupported object type
```

# repeat error
```

cat>/home/tmp/release.json<<EOF
{
  "push": {
    "head": {
      "ref": "develop"
    },
    "base": {
      "ref": "develop"
    }
  }
}
EOF

cat>/home/tmp/my.secrets<<EOF
GITHUB_TOKEN=xxx
DOCKERHUB_USERNAME=xxx
DOCKERHUB_TOKEN=xxx
EOF

```

my command is `act  --secret-file /home/tmp/my.secrets --artifact-server-path /tmp/dc --verbose  -e /home/tmp/release.json  -j bimg`

What's wrong about the event content? I have evet got the following action to fetch the full content of event, but not works.
```
- name: Dump GitHub context
  id: github_context_step
  run: echo '${{ toJSON(github) }}'
```

```
{
    "after": "61a8b3560d0b5242427772b0035416b427ca5c92",
    "base_ref": null,
    "before": "0000000000000000000000000000000000000000",
    "commits": [
      {
 
        "committer": {
          "email": "noreply@github.com",
          "name": "GitHub",
          "username": "web-flow"
        },
        "distinct": true,
        "id": "a71f3700fd1988faf4b3da2ed1d31122d641d52e",
        "message": "security fix, fix python cli pyyaml from 5.3 to 5.4 (#984)",
        "timestamp": "2022-12-30T16:45:35+08:00",
        "tree_id": "baa51edf94d8546e87bfedf6a6df4b6fb35e794c",
        "url": "https://github.com/tornado404/PaddleFlow/commit/a71f3700fd1988faf4b3da2ed1d31122d641d52e"
      },
      {
        "author": {
          "email": "zhongzichao@baidu.com",
          "name": "zhongzichao",
          "username": "tornado404"
        },
        "committer": {
          "email": "noreply@github.com",
          "name": "GitHub",
          "username": "web-flow"
        },
        "distinct": true,
        "id": "fa1448ca764d88110bcd0289058147f4cc34586e",
        "message": "reduce relations between job and task Listener (#983)\n\n* reduce relations between job and task Listener\r\n* only change the registerTaskListener\r\n* fix taskclient without jobClient.AddEventListener\r\n* create only one go routine\r\n* create only one go routine\r\n* return nil\r\n* adjust log level for sync job informer",
        "timestamp": "2023-01-03T11:01:52+08:00",
        "tree_id": "7e83e0043196e086cbb405229138f3f48b6520ac",
        "url": "https://github.com/tornado404/PaddleFlow/commit/fa1448ca764d88110bcd0289058147f4cc34586e"
      },
      {
        "author": {
          "email": "zhongzichao@baidu.com",
          "name": "zhongzichao",
          "username": "tornado404"
        },
        "committer": {
          "email": "zhongzichao@baidu.com",
          "name": "zhongzichao",
          "username": "tornado404"
        },
        "distinct": true,
        "id": "70b354347a4978eec8d5169603edb0f743532810",
        "message": "improve dockerfile and release",
        "timestamp": "2023-01-04T10:32:03+08:00",
        "tree_id": "e5ec9ceb3d21bd751be8b12b106bf124cbab7f2f",
        "url": "https://github.com/tornado404/PaddleFlow/commit/70b354347a4978eec8d5169603edb0f743532810"
      },
      {
        "author": {
          "email": "zhongzichao@baidu.com",
          "name": "zhongzichao",
          "username": "tornado404"
        },
        "committer": {
          "email": "zhongzichao@baidu.com",
          "name": "zhongzichao",
          "username": "tornado404"
        },
        "distinct": true,
        "id": "61a8b3560d0b5242427772b0035416b427ca5c92",
        "message": "improve dockerfile and release",
        "timestamp": "2023-01-04T14:44:53+08:00",
        "tree_id": "f8c6c465b44e197b4a5cf9f3becc25647d10535f",
        "url": "https://github.com/tornado404/PaddleFlow/commit/61a8b3560d0b5242427772b0035416b427ca5c92"
      }
    ],
    "compare": "https://github.com/tornado404/PaddleFlow/compare/a71f3700fd19^...61a8b3560d0b",
    "created": true,
    "deleted": false,
    "forced": false,
    "head_commit": {
      "author": {
        "email": "zhongzichao@baidu.com",
        "name": "zhongzichao",
        "username": "tornado404"
      },
      "committer": {
        "email": "zhongzichao@baidu.com",
        "name": "zhongzichao",
        "username": "tornado404"
      },
      "distinct": true,
      "id": "61a8b3560d0b5242427772b0035416b427ca5c92",
      "message": "improve dockerfile and release",
      "timestamp": "2023-01-04T14:44:53+08:00",
      "tree_id": "f8c6c465b44e197b4a5cf9f3becc25647d10535f",
      "url": "https://github.com/tornado404/PaddleFlow/commit/61a8b3560d0b5242427772b0035416b427ca5c92"
    },
    "pusher": {
      "email": "zhongzichao@baidu.com",
      "name": "tornado404"
    },
    "ref": "refs/heads/fix_dockerfile",
    "repository": {
      "allow_forking": true,
      "archive_url": "https://api.github.com/repos/tornado404/PaddleFlow/{archive_format}{/ref}",
      "archived": false,
      "assignees_url": "https://api.github.com/repos/tornado404/PaddleFlow/assignees{/user}",
      "blobs_url": "https://api.github.com/repos/tornado404/PaddleFlow/git/blobs{/sha}",
      "branches_url": "https://api.github.com/repos/tornado404/PaddleFlow/branches{/branch}",
      "clone_url": "https://github.com/tornado404/PaddleFlow.git",
      "collaborators_url": "https://api.github.com/repos/tornado404/PaddleFlow/collaborators{/collaborator}",
      "comments_url": "https://api.github.com/repos/tornado404/PaddleFlow/comments{/number}",
      "commits_url": "https://api.github.com/repos/tornado404/PaddleFlow/commits{/sha}",
      "compare_url": "https://api.github.com/repos/tornado404/PaddleFlow/compare/{base}...{head}",
      "contents_url": "https://api.github.com/repos/tornado404/PaddleFlow/contents/{+path}",
      "contributors_url": "https://api.github.com/repos/tornado404/PaddleFlow/contributors",
      "created_at": 1647433161,
      "default_branch": "develop",
      "deployments_url": "https://api.github.com/repos/tornado404/PaddleFlow/deployments",
      "description": null,
      "disabled": false,
      "downloads_url": "https://api.github.com/repos/tornado404/PaddleFlow/downloads",
      "events_url": "https://api.github.com/repos/tornado404/PaddleFlow/events",
      "fork": true,
      "forks": 0,
      "forks_count": 0,
      "forks_url": "https://api.github.com/repos/tornado404/PaddleFlow/forks",
      "full_name": "tornado404/PaddleFlow",
      "git_commits_url": "https://api.github.com/repos/tornado404/PaddleFlow/git/commits{/sha}",
      "git_refs_url": "https://api.github.com/repos/tornado404/PaddleFlow/git/refs{/sha}",
      "git_tags_url": "https://api.github.com/repos/tornado404/PaddleFlow/git/tags{/sha}",
      "git_url": "git://github.com/tornado404/PaddleFlow.git",
      "has_discussions": false,
      "has_downloads": true,
      "has_issues": false,
      "has_pages": false,
      "has_projects": true,
      "has_wiki": true,
      "homepage": null,
      "hooks_url": "https://api.github.com/repos/tornado404/PaddleFlow/hooks",
      "html_url": "https://github.com/tornado404/PaddleFlow",
      "id": 470570253,
      "is_template": false,
      "issue_comment_url": "https://api.github.com/repos/tornado404/PaddleFlow/issues/comments{/number}",
      "issue_events_url": "https://api.github.com/repos/tornado404/PaddleFlow/issues/events{/number}",
      "issues_url": "https://api.github.com/repos/tornado404/PaddleFlow/issues{/number}",
      "keys_url": "https://api.github.com/repos/tornado404/PaddleFlow/keys{/key_id}",
      "labels_url": "https://api.github.com/repos/tornado404/PaddleFlow/labels{/name}",
      "language": "Go",
      "languages_url": "https://api.github.com/repos/tornado404/PaddleFlow/languages",
      "license": {
        "key": "apache-2.0",
        "name": "Apache License 2.0",
        "node_id": "MDc6TGljZW5zZTI=",
        "spdx_id": "Apache-2.0",
        "url": "https://api.github.com/licenses/apache-2.0"
      },
      "master_branch": "develop",
      "merges_url": "https://api.github.com/repos/tornado404/PaddleFlow/merges",
      "milestones_url": "https://api.github.com/repos/tornado404/PaddleFlow/milestones{/number}",
      "mirror_url": null,
      "name": "PaddleFlow",
      "node_id": "R_kgDOHAxVDQ",
      "notifications_url": "https://api.github.com/repos/tornado404/PaddleFlow/notifications{?since,all,participating}",
      "open_issues": 1,
      "open_issues_count": 1,
      "owner": {
        "avatar_url": "https://avatars.githubusercontent.com/u/26156094?v=4",
        "email": "zhongzichao@baidu.com",
        "events_url": "https://api.github.com/users/tornado404/events{/privacy}",
        "followers_url": "https://api.github.com/users/tornado404/followers",
        "following_url": "https://api.github.com/users/tornado404/following{/other_user}",
        "gists_url": "https://api.github.com/users/tornado404/gists{/gist_id}",
        "gravatar_id": "",
        "html_url": "https://github.com/tornado404",
        "id": 26156094,
        "login": "tornado404",
        "name": "tornado404",
        "node_id": "MDQ6VXNlcjI2MTU2MDk0",
        "organizations_url": "https://api.github.com/users/tornado404/orgs",
        "received_events_url": "https://api.github.com/users/tornado404/received_events",
        "repos_url": "https://api.github.com/users/tornado404/repos",
        "site_admin": false,
        "starred_url": "https://api.github.com/users/tornado404/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/tornado404/subscriptions",
        "type": "User",
        "url": "https://api.github.com/users/tornado404"
      },
      "private": false,
      "pulls_url": "https://api.github.com/repos/tornado404/PaddleFlow/pulls{/number}",
      "pushed_at": 1672814783,
      "releases_url": "https://api.github.com/repos/tornado404/PaddleFlow/releases{/id}",
      "size": 12017,
      "ssh_url": "git@github.com:tornado404/PaddleFlow.git",
      "stargazers": 1,
      "stargazers_count": 1,
      "stargazers_url": "https://api.github.com/repos/tornado404/PaddleFlow/stargazers",
      "statuses_url": "https://api.github.com/repos/tornado404/PaddleFlow/statuses/{sha}",
      "subscribers_url": "https://api.github.com/repos/tornado404/PaddleFlow/subscribers",
      "subscription_url": "https://api.github.com/repos/tornado404/PaddleFlow/subscription",
      "svn_url": "https://github.com/tornado404/PaddleFlow",
      "tags_url": "https://api.github.com/repos/tornado404/PaddleFlow/tags",
      "teams_url": "https://api.github.com/repos/tornado404/PaddleFlow/teams",
      "topics": [],
      "trees_url": "https://api.github.com/repos/tornado404/PaddleFlow/git/trees{/sha}",
      "updated_at": "2022-06-14T05:50:19Z",
      "url": "https://github.com/tornado404/PaddleFlow",
      "visibility": "public",
      "watchers": 1,
      "watchers_count": 1,
      "web_commit_signoff_required": false
    },
    "sender": {
      "avatar_url": "https://avatars.githubusercontent.com/u/26156094?v=4",
      "events_url": "https://api.github.com/users/tornado404/events{/privacy}",
      "followers_url": "https://api.github.com/users/tornado404/followers",
      "following_url": "https://api.github.com/users/tornado404/following{/other_user}",
      "gists_url": "https://api.github.com/users/tornado404/gists{/gist_id}",
      "gravatar_id": "",
      "html_url": "https://github.com/tornado404",
      "id": 26156094,
      "login": "tornado404",
      "node_id": "MDQ6VXNlcjI2MTU2MDk0",
      "organizations_url": "https://api.github.com/users/tornado404/orgs",
      "received_events_url": "https://api.github.com/users/tornado404/received_events",
      "repos_url": "https://api.github.com/users/tornado404/repos",
      "site_admin": false,
      "starred_url": "https://api.github.com/users/tornado404/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/tornado404/subscriptions",
      "type": "User",
      "url": "https://api.github.com/users/tornado404"
    }
  } 
```</div>


Discussion / hints:
Did you figure it out? Having the same issue right now, very frustrating.
Same here
@tornado404 it happened to me when I had a subdirectory with .git directory in it

Fix patch:
diff --git a/pkg/model/github_context.go b/pkg/model/github_context.go
index 5ed3d962ffa..71221a5926b 100644
--- a/pkg/model/github_context.go
+++ b/pkg/model/github_context.go
@@ -168,7 +168,7 @@ func (ghc *GithubContext) SetRepositoryAndOwner(ctx context.Context, githubInsta
 	if ghc.Repository == "" {
 		repo, err := git.FindGithubRepo(ctx, repoPath, githubInstance, remoteName)
 		if err != nil {
-			common.Logger(ctx).Warningf("unable to get git repo: %v", err)
+			common.Logger(ctx).Warningf("unable to get git repo (githubInstance: %v; remoteName: %v, repoPath: %v): %v", githubInstance, remoteName, repoPath, err)
 			return
 		}
 		ghc.Repository = repo


Test patch: