Our project has the following workflow setup:
- Library workflow
- iOS Sample workflow
- macOS Sample workflow
A git push will trigger the Library workflow, which chains the iOS Sample and macOS Sample workflows as a follow-on.
The reason we’ve split it up is so that each workflow represents independant concerns, and could be run separately.
However, when the workflows are chained, they are not run in isolation, and the git step will fail on subsequent workflows for pull requests (but not when building off master)
The error is:
Git clone repository
=> git "remote" "-v"
=> git "reset" "--hard" "HEAD"
=> git "clean" "-xdf"
=> git "submodule" "foreach" "git" "reset" "--hard" "HEAD"
=> git "submodule" "foreach" "git" "clean" "-xdf"
=> git "init"
=> git "fetch" "origin" "pull/87/merge:pull/87"
0 attempt failed:
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
fatal: Refusing to fetch into current branch refs/heads/pull/87 of non-bare repository
Retrying...
=> git "fetch" "origin" "pull/87/merge:pull/87"
1 attempt failed:
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
fatal: Refusing to fetch into current branch refs/heads/pull/87 of non-bare repository
Retrying...
=> git "fetch" "origin" "pull/87/merge:pull/87"
2 attempt failed:
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
fatal: Refusing to fetch into current branch refs/heads/pull/87 of non-bare repository
Failed, error: Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
fatal: Refusing to fetch into current branch refs/heads/pull/87 of non-bare repository
Deleting the git step in the follow-on workflows resolves the issue (it’s an unnecessary step when run in that sequence), but then they can’t be run independently.
What would you recommend? Can the git workflow be updated to handle this gracefully? Is there a way we should reset the working directory before each workflow, or should we move all git setup steps to “parent” workflows designed to be run independently, and chain to workflows that are only used as follow-on workflows?