Unable to determine current hash with `git rev-parse HEAD`
See original GitHub issueI’m having this error when I activate temporaryPublicStorage: true
.
This is the run: https://github.com/frontity/frontity/pull/244/checks?check_run_id=339869140
And this is the workflow job:
lighthouse:
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Audit URLs using Lighthouse
uses: treosh/lighthouse-ci-action@v2
with:
temporaryPublicStorage: true
urls: |
https://mars-theme-frontity.worona.now.sh/
https://mars-theme-frontity.worona.now.sh/2016/the-beauties-of-gullfoss/
By looking at the specific line that throws the error:
https://github.com/GoogleChrome/lighthouse-ci/blob/master/packages/utils/src/build-context.js#L54
it looks like lighthouse is trying to use git rev-list -n1 HEAD
to get the commit hash.
Just before that, it looks for some environment variables. I have solved the issue adding the env LHCI_BUILD_CONTEXT__CURRENT_HASH
populated with ${{ github.sha }}
.
I’m not sure why I am having this problem, but in case you can reproduce it, maybe this package should add the LHCI_BUILD_CONTEXT__CURRENT_HASH
env variable by default:
env:
LHCI_BUILD_CONTEXT__CURRENT_HASH: ${{ github.sha }}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Actually, I figured it out…
Looking at the log for
checkout@v2
I saw this:As I’m using a
self-hosted
runner I had an old version of git… upgrading it… now there is indeed a.git
folder in my root directory and everything works as expected.Related LHCI issue: https://github.com/GoogleChrome/lighthouse-ci/issues/151