4

I am setting up GitHub Actions for an Android project private repo which has multiple git submodules and my workflow cannot even pass the checkout step!

I know that it might be the authentication issue but have no idea how to fix it! I am wondering since the CI is for GitHub it has access to all the company's repos and doesn't require any token or hash key.

This is the checkout step in yml file:

 - name: Chrckout repo
   uses: actions/checkout@v1
   with:
    submodules: true
    lfs: true

and here is some parts of the log (sorry that I had to obfuscate some parts because of project confidentiality but it should be readable):

2019-09-29T13:03:39.9185317Z ##[group]Run actions/checkout@v1
2019-09-29T13:03:39.9272863Z with:
2019-09-29T13:03:39.9273270Z   submodules: true
2019-09-29T13:03:39.9273443Z   lfs: true
2019-09-29T13:03:39.9273636Z ##[endgroup]
2019-09-29T13:03:40.9117862Z Added matchers: 'checkout-git'. Problem matchers scan action output for known warning or error strings and report these inline.
2019-09-29T13:03:40.9118799Z ##[add-matcher]/home/runner/work/_temp/git_edd66dd0-526a-44d1-97ad-a70a018bc61e.json
2019-09-29T13:03:40.9137013Z Syncing repository: ***/***-Android
2019-09-29T13:03:40.9145133Z ##[command]git version
2019-09-29T13:03:40.9145665Z git version 2.23.0
2019-09-29T13:03:40.9146108Z ##[command]git lfs version
2019-09-29T13:03:41.5663318Z git-lfs/2.8.0 (GitHub; linux amd64; go 1.12.6)
2019-09-29T13:03:41.6007068Z ##[command]git init "/home/runner/work/***-Android/***-Android"
2019-09-29T13:03:41.6453117Z Initialized empty Git repository in /home/runner/work/***-Android/***-Android/.git/
2019-09-29T13:03:41.6502397Z ##[command]git remote add origin https://github.com/***/***-Android
2019-09-29T13:03:41.6686542Z ##[command]git config gc.auto 0
2019-09-29T13:03:41.6767746Z ##[command]git config --get-all http.https://github.com/***/***-Android.extraheader
2019-09-29T13:03:41.6826722Z ##[command]git config --get-all http.proxy
2019-09-29T13:03:41.6946989Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --tags --prune --progress --no-recurse-submodules origin +refs/heads/*:refs/remotes/origin/*
2019-09-29T13:03:42.5443344Z remote: Enumerating objects: 1483, done.        
2019-09-29T13:03:42.5444124Z remote: Counting objects:   0% (1/1483)        
2019-09-29T13:03:42.5444498Z remote: Counting objects:   1% (15/1483)        
.
.
.       
2019-09-29T13:03:42.5493616Z remote: Counting objects:  99% (1469/1483)        
2019-09-29T13:03:42.5493904Z remote: Counting objects: 100% (1483/1483)        
2019-09-29T13:03:42.5494370Z remote: Counting objects: 100% (1483/1483), done.        
2019-09-29T13:03:42.5495148Z remote: Compressing objects:   0% (1/727)        
2019-09-29T13:03:42.5495381Z remote: Compressing objects:   1% (8/727)
.
.
.        
2019-09-29T13:03:42.5898942Z remote: Compressing objects:  99% (720/727)        
2019-09-29T13:03:42.5899526Z remote: Compressing objects: 100% (727/727)        
2019-09-29T13:03:42.5899818Z remote: Compressing objects: 100% (727/727), done.        
2019-09-29T13:03:42.6030874Z 
2019-09-29T13:03:42.6031956Z                                                                                 
2019-09-29T13:03:42.6181873Z Receiving objects:   0% (1/98154)
2019-09-29T13:03:42.6182681Z 
2019-09-29T13:03:42.6184320Z                                                                                 
2019-09-29T13:03:42.6327511Z Receiving objects:   1% (982/98154)
2019-09-29T13:03:42.6328000Z 
2019-09-29T13:03:42.6328418Z                                                                                 
2019-09-29T13:03:42.6459740Z Receiving objects:   2% (1964/98154)
2019-09-29T13:03:42.6459933Z 
2019-09-29T13:03:42.6460265Z                                                                                 

.
.
.
2019-09-29T13:03:46.7921902Z 
2019-09-29T13:03:46.7923021Z                                                                                 
2019-09-29T13:03:46.8059761Z Receiving objects:  99% (97173/98154), 140.24 MiB | 35.06 MiB/s
2019-09-29T13:03:46.8061958Z remote: Total 98154 (delta 502), reused 1355 (delta 448), pack-reused 96671        
2019-09-29T13:03:46.8096377Z 
2019-09-29T13:03:46.8097502Z                                                                                 
2019-09-29T13:03:46.8099271Z Receiving objects: 100% (98154/98154), 140.24 MiB | 35.06 MiB/s
2019-09-29T13:03:46.8100178Z 
2019-09-29T13:03:46.8101120Z                                                                                 
2019-09-29T13:03:46.8102099Z Receiving objects: 100% (98154/98154), 150.44 MiB | 35.77 MiB/s, done.
2019-09-29T13:03:46.8177656Z 
2019-09-29T13:03:46.8179286Z                                                                                 
2019-09-29T13:03:46.8247809Z Resolving deltas:   0% (0/50478)
2019-09-29T13:03:46.8249644Z 
2019-09-29T13:03:46.8250044Z                                                                                 
2019-09-29T13:03:46.8275539Z Resolving deltas:   1% (606/50478)
2019-09-29T13:03:46.8275687Z 
2019-09-29T13:03:46.8275943Z                                                                                 

.
.
.                                                                               
2019-09-29T13:03:47.8181717Z Resolving deltas:  99% (49974/50478)
2019-09-29T13:03:47.8245769Z 
2019-09-29T13:03:47.8246196Z                                                                                 
2019-09-29T13:03:47.8246479Z Resolving deltas: 100% (50478/50478)
2019-09-29T13:03:47.8246612Z 
2019-09-29T13:03:47.8247201Z                                                                                 
2019-09-29T13:03:47.8247576Z Resolving deltas: 100% (50478/50478), done.
2019-09-29T13:03:51.8552178Z From https://github.com/***/***-Android
2019-09-29T13:03:51.8556296Z  * [new branch]      refactor -> origin/refactor
.
.
.
2019-09-29T13:03:51.9186875Z  * [new tag]         v0.63.0                -> v0.63.0
.
.
.
2019-09-29T13:03:51.9858238Z ##[command]git checkout --progress --force 4e746ed66b5dc33310ebdc6eb12b945e385d9c4a
2019-09-29T13:03:52.5800307Z Note: switching to '4e746ed66b5dc33310ebdc6eb12b945e385d9c4a'.
2019-09-29T13:03:52.5801297Z 
2019-09-29T13:03:52.5802472Z You are in 'detached HEAD' state. You can look around, make experimental
2019-09-29T13:03:52.5803107Z changes and commit them, and you can discard any commits you make in this
2019-09-29T13:03:52.5803598Z state without impacting any branches by switching back to a branch.
2019-09-29T13:03:52.5803933Z 
2019-09-29T13:03:52.5804367Z If you want to create a new branch to retain commits you create, you may
2019-09-29T13:03:52.5805414Z do so (now or later) by using -c with the switch command. Example:
2019-09-29T13:03:52.5806068Z 
2019-09-29T13:03:52.5806726Z   git switch -c <new-branch-name>
2019-09-29T13:03:52.5807094Z 
2019-09-29T13:03:52.5807511Z Or undo this operation with:
2019-09-29T13:03:52.5807830Z 
2019-09-29T13:03:52.5809354Z   git switch -
2019-09-29T13:03:52.5809855Z 
2019-09-29T13:03:52.5810364Z Turn off this advice by setting config variable advice.detachedHead to false
2019-09-29T13:03:52.5810742Z 
2019-09-29T13:03:52.5811258Z HEAD is now at 4e746ed66 submodules 99
2019-09-29T13:03:52.7096856Z ##[command]git submodule sync
2019-09-29T13:03:52.7930660Z ##[command]git -c http.https://github.com.extraheader="AUTHORIZATION: basic ***" submodule update --init --force
2019-09-29T13:03:52.8223899Z Submodule 'proto' (git@github.***/***-Protobuf.git) registered for path 'c/device/proto/src/main/proto'
2019-09-29T13:03:52.8229867Z Submodule 'json' (git@github.***/json.git) registered for path 'c/n/a/json'
2019-09-29T13:03:52.8234606Z Submodule 'v' (git@github.com:***/V.git) registered for path 'c/n/a/v'
2019-09-29T13:03:52.8239790Z Submodule 'd' (git@github.com:***/D.git) registered for path 'c/n/d/d'
2019-09-29T13:03:52.8383255Z Cloning into '/home/runner/work/***-Android/***-Android/c/device/proto/src/main/proto'...
2019-09-29T13:03:53.0073411Z Host key verification failed.
2019-09-29T13:03:53.0191036Z ##[error]fatal: Could not read from remote repository.
2019-09-29T13:03:53.0204269Z 
2019-09-29T13:03:53.0204574Z Please make sure you have the correct access rights
2019-09-29T13:03:53.0204816Z and the repository exists.
2019-09-29T13:03:53.0207224Z ##[error]fatal: clone of 'git@github.com:***/***-Protobuf.git' into submodule path '/home/runner/work/***-Android/***-Android/c/device/proto/src/main/proto' failed
2019-09-29T13:03:53.0208627Z Failed to clone 'c/device/proto/src/main/proto'. Retry scheduled
2019-09-29T13:03:53.0210196Z Cloning into '/home/runner/work/***-Android/***-Android/c/n/a/json'...
2019-09-29T13:03:53.0895134Z Host key verification failed.
2019-09-29T13:03:53.0901281Z ##[error]fatal: Could not read from remote repository.
2019-09-29T13:03:53.0901797Z 
2019-09-29T13:03:53.0902198Z Please make sure you have the correct access rights
2019-09-29T13:03:53.0902587Z and the repository exists.
2019-09-29T13:03:53.0910343Z ##[error]fatal: clone of 'git@github.com:***/json.git' into submodule path '/home/runner/work/***-Android/***-Android/c/n/a/json' failed
2019-09-29T13:03:53.0911390Z Failed to clone 'c/n/a/json'. Retry scheduled
2019-09-29T13:03:53.0938254Z Cloning into '/home/runner/work/***-Android/***-Android/c/n/a/v'...
2019-09-29T13:03:53.1691373Z Host key verification failed.
2019-09-29T13:03:53.1698028Z ##[error]fatal: Could not read from remote repository.
2019-09-29T13:03:53.1702098Z 
2019-09-29T13:03:53.1703485Z Please make sure you have the correct access rights
2019-09-29T13:03:53.1704308Z and the repository exists.
2019-09-29T13:03:53.1710654Z ##[error]fatal: clone of 'git@github.com:***/V.git' into submodule path '/home/runner/work/***-Android/***-Android/c/n/a/v' failed
2019-09-29T13:03:53.1713573Z Failed to clone 'c/n/a/v'. Retry scheduled
2019-09-29T13:03:53.1741011Z Cloning into '/home/runner/work/***-Android/***-Android/c/n/d/d'...
2019-09-29T13:03:53.2511414Z Host key verification failed.
2019-09-29T13:03:53.2514791Z ##[error]fatal: Could not read from remote repository.
2019-09-29T13:03:53.2526450Z 
2019-09-29T13:03:53.2526930Z Please make sure you have the correct access rights
2019-09-29T13:03:53.2527255Z and the repository exists.
2019-09-29T13:03:53.2528958Z ##[error]fatal: clone of 'git@github.com:***/D.git' into submodule path '/home/runner/work/***-Android/***-Android/c/n/d/d' failed
2019-09-29T13:03:53.2530699Z Failed to clone 'c/n/d/d'. Retry scheduled
2019-09-29T13:03:53.2558956Z Cloning into '/home/runner/work/***-Android/***-Android/c/device/proto/src/main/proto'...
2019-09-29T13:03:53.3373002Z Host key verification failed.
2019-09-29T13:03:53.3378381Z ##[error]fatal: Could not read from remote repository.
2019-09-29T13:03:53.3380657Z 
2019-09-29T13:03:53.3381349Z Please make sure you have the correct access rights
2019-09-29T13:03:53.3381662Z and the repository exists.
2019-09-29T13:03:53.3394503Z ##[error]fatal: clone of 'git@github.com:***/***-Protobuf.git' into submodule path '/home/runner/work/***-Android/***-Android/c/device/proto/src/main/proto' failed
2019-09-29T13:03:53.3400724Z Failed to clone 'c/device/proto/src/main/proto' a second time, aborting
2019-09-29T13:03:53.3487425Z Removed matchers: 'checkout-git'
2019-09-29T13:03:53.3487829Z ##[remove-matcher owner=checkout-git]
2019-09-29T13:03:53.3509685Z ##[error]Git submodule update failed with exit code: 1
2019-09-29T13:03:53.3905892Z ##[error]Exit code 1 returned from process: file name '/home/runner/runners/2.158.0/bin/Runner.PluginHost', arguments 'action "GitHub.Runner.Plugins.Repository.CheckoutTask, Runner.Plugins"'.
2019-09-29T13:03:53.4082152Z Cleaning up orphan processes
Mohsen Mirhoseini
  • 8,454
  • 5
  • 34
  • 59
  • Looks like the culprit is "Host key verification failed"? If yes, this has been discussed before https://stackoverflow.com/questions/13363553/git-error-host-key-verification-failed-when-connecting-to-remote-repository Are the suggested solutions there of any help? – sbat Oct 08 '19 at 09:34
  • @sbat thanks, I will check – Mohsen Mirhoseini Oct 08 '19 at 10:35

1 Answers1

5

The default secret GITHUB_TOKEN that the checkout action is using is only scoped to that repository. You cannot use it to access other repositories.

Try using a repo scoped token instead. Create one at https://github.com/settings/tokens and then add it as a secret to the repository your workflow runs in. It will be under https://github.com/[username]/[repo]/settings/secrets

Then pass this secret via the token parameter to the checkout action.

- uses: actions/checkout@v1
  with:
    submodules: true
    token: ${{ secrets.REPO_SCOPED_TOKEN }}
peterevans
  • 34,297
  • 7
  • 84
  • 83
  • Nice! The token parameter was not noted anywhere in documents! I will try this. – Mohsen Mirhoseini Oct 10 '19 at 05:32
  • The `token` parameter description is a bit hidden. See here: https://github.com/actions/checkout/blob/master/action.yml#L8-L9 – peterevans Oct 10 '19 at 05:34
  • I don't get it :( When I use this as suggested (generate a personal access token from a user which has access to the submodule repo) I still get `Host key verification failed.` Error in my Github Action using the checkout workflow with submodules and the token (injected via secrets). The repo is owned by an organization but such cannot generate those dev tokens. I thought the problem is that I generated the token for another account than the repo owner. – hb0 Dec 10 '19 at 14:56