Github pages action: fatal: not in a git directory
felixperezc opened this issue · 16 comments
Describe the bug
Github page action: Doesn't work..
Reproduction Steps
Logs
Run JamesIves/github-pages-deploy-action@4.2.0
/usr/bin/docker exec xxxx sh -c "cat /etc/*release | grep ^ID"
GitHub Pages Deploy Action 🚀
💖 Support: https://github.com/sponsors/JamesIves
📣 Maintained by James Ives: https://jamesiv.es/
🚀 Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action
❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
Checking configuration and starting deployment… 🚦
The operating system you're using is not supported and results may be varied. Please refer to the documentation for more details. ❗
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config user.name xxx
fatal: not in a git directory
Error: There was an error initializing the repository: The process '/usr/bin/git' failed with exit code 1[28] ❌
Deployment failed! ❌
Workflow
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@4.2.0
with:
branch: gh-pages
folder: build/docs
Please provide relevant logs and workflow examples
Since we're seeing the same issue over at https://github.com/cp2k/dbcsr, here's our workflow definition:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
container:
image: ghcr.io/cp2k/dbcsr-build-env-ubuntu-20.04:develop
volumes:
- "/etc/ssh/ssh_known_hosts:/etc/ssh/ssh_known_hosts:ro"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Configure
run: |
mkdir -p build
cd build
cmake -G Ninja \
-DUSE_MPI=ON \
-DUSE_OPENMP=ON \
-DUSE_SMM=libxsmm \
-DMPI_EXECUTABLE_SUFFIX=.mpich \
..
- name: Build
run: |
cmake --build build -- doc
touch build/doc/.nojekyll
- name: Deploy Development Documentation
if: github.repository == 'cp2k/dbcsr' && github.ref == 'refs/heads/develop'
uses: JamesIves/github-pages-deploy-action@releases/v4
with:
branch: gh-pages
folder: build/doc
target-folder: develop
clean: true
clean-exclude: |
releases/
ssh-key: ${{ secrets.SSH_DEPLOY_KEY }}
Can you provide the logs too? My assumption is due to the use of a container, but it's difficult to say.
at least for me there is not much more in the logs (even with ACTIONS_STEP_DEBUG=true
, full log file attached below):
[...]
2022-04-22T07:49:44.9008714Z ##[debug]Starting: Deploy Development Documentation
2022-04-22T07:49:44.9041704Z ##[debug]Loading inputs
2022-04-22T07:49:44.9045405Z ##[debug]Evaluating: secrets.SSH_DEPLOY_KEY
2022-04-22T07:49:44.9045994Z ##[debug]Evaluating Index:
2022-04-22T07:49:44.9046506Z ##[debug]..Evaluating secrets:
2022-04-22T07:49:44.9047028Z ##[debug]..=> Object
2022-04-22T07:49:44.9047530Z ##[debug]..Evaluating String:
2022-04-22T07:49:44.9048030Z ##[debug]..=> 'SSH_DEPLOY_KEY'
2022-04-22T07:49:44.9049024Z ##[debug]=> '***
2022-04-22T07:49:44.9049743Z ##[debug]***
2022-04-22T07:49:44.9050436Z ##[debug]***
2022-04-22T07:49:44.9051096Z ##[debug]***
2022-04-22T07:49:44.9051733Z ##[debug]***
2022-04-22T07:49:44.9052395Z ##[debug]***
2022-04-22T07:49:44.9053042Z ##[debug]***
2022-04-22T07:49:44.9053714Z ##[debug]***
2022-04-22T07:49:44.9054333Z ##[debug]***
2022-04-22T07:49:44.9054952Z ##[debug]***
2022-04-22T07:49:44.9055557Z ##[debug]***
2022-04-22T07:49:44.9056259Z ##[debug]***
2022-04-22T07:49:44.9056944Z ##[debug]***
2022-04-22T07:49:44.9057613Z ##[debug]***
2022-04-22T07:49:44.9058242Z ##[debug]***
2022-04-22T07:49:44.9058911Z ##[debug]***
2022-04-22T07:49:44.9059531Z ##[debug]***
2022-04-22T07:49:44.9060214Z ##[debug]***
2022-04-22T07:49:44.9060811Z ##[debug]***
2022-04-22T07:49:44.9061694Z ##[debug]***
2022-04-22T07:49:44.9062329Z ##[debug]***
2022-04-22T07:49:44.9062992Z ##[debug]***
2022-04-22T07:49:44.9063683Z ##[debug]***
2022-04-22T07:49:44.9064320Z ##[debug]***
2022-04-22T07:49:44.9064990Z ##[debug]***
2022-04-22T07:49:44.9065634Z ##[debug]***
2022-04-22T07:49:44.9066314Z ##[debug]***
2022-04-22T07:49:44.9066923Z ##[debug]***
2022-04-22T07:49:44.9067607Z ##[debug]***
2022-04-22T07:49:44.9068222Z ##[debug]***
2022-04-22T07:49:44.9068902Z ##[debug]***
2022-04-22T07:49:44.9069597Z ##[debug]***
2022-04-22T07:49:44.9070276Z ##[debug]***
2022-04-22T07:49:44.9071127Z ##[debug]***
2022-04-22T07:49:44.9071817Z ##[debug]***
2022-04-22T07:49:44.9072496Z ##[debug]***
2022-04-22T07:49:44.9073183Z ##[debug]***
2022-04-22T07:49:44.9073853Z ##[debug]***
2022-04-22T07:49:44.9074503Z ##[debug]***
2022-04-22T07:49:44.9075145Z ##[debug]***
2022-04-22T07:49:44.9075794Z ##[debug]***
2022-04-22T07:49:44.9076486Z ##[debug]***
2022-04-22T07:49:44.9077242Z ##[debug]***
2022-04-22T07:49:44.9077850Z ##[debug]***
2022-04-22T07:49:44.9078551Z ##[debug]***
2022-04-22T07:49:44.9079214Z ##[debug]***
2022-04-22T07:49:44.9079902Z ##[debug]***
2022-04-22T07:49:44.9080556Z ##[debug]***
2022-04-22T07:49:44.9081064Z ##[debug]***'
2022-04-22T07:49:44.9081843Z ##[debug]Result: '***
2022-04-22T07:49:44.9082559Z ##[debug]***
2022-04-22T07:49:44.9083212Z ##[debug]***
2022-04-22T07:49:44.9083812Z ##[debug]***
2022-04-22T07:49:44.9084443Z ##[debug]***
2022-04-22T07:49:44.9085108Z ##[debug]***
2022-04-22T07:49:44.9085754Z ##[debug]***
2022-04-22T07:49:44.9086426Z ##[debug]***
2022-04-22T07:49:44.9087054Z ##[debug]***
2022-04-22T07:49:44.9087669Z ##[debug]***
2022-04-22T07:49:44.9088288Z ##[debug]***
2022-04-22T07:49:44.9088952Z ##[debug]***
2022-04-22T07:49:44.9089633Z ##[debug]***
2022-04-22T07:49:44.9090297Z ##[debug]***
2022-04-22T07:49:44.9090958Z ##[debug]***
2022-04-22T07:49:44.9091592Z ##[debug]***
2022-04-22T07:49:44.9092211Z ##[debug]***
2022-04-22T07:49:44.9092891Z ##[debug]***
2022-04-22T07:49:44.9093499Z ##[debug]***
2022-04-22T07:49:44.9094106Z ##[debug]***
2022-04-22T07:49:44.9094729Z ##[debug]***
2022-04-22T07:49:44.9095395Z ##[debug]***
2022-04-22T07:49:44.9096065Z ##[debug]***
2022-04-22T07:49:44.9096673Z ##[debug]***
2022-04-22T07:49:44.9097330Z ##[debug]***
2022-04-22T07:49:44.9097958Z ##[debug]***
2022-04-22T07:49:44.9098629Z ##[debug]***
2022-04-22T07:49:44.9099230Z ##[debug]***
2022-04-22T07:49:44.9099897Z ##[debug]***
2022-04-22T07:49:44.9100505Z ##[debug]***
2022-04-22T07:49:44.9101281Z ##[debug]***
2022-04-22T07:49:44.9101981Z ##[debug]***
2022-04-22T07:49:44.9102655Z ##[debug]***
2022-04-22T07:49:44.9103303Z ##[debug]***
2022-04-22T07:49:44.9103978Z ##[debug]***
2022-04-22T07:49:44.9104642Z ##[debug]***
2022-04-22T07:49:44.9105317Z ##[debug]***
2022-04-22T07:49:44.9105970Z ##[debug]***
2022-04-22T07:49:44.9106601Z ##[debug]***
2022-04-22T07:49:44.9107226Z ##[debug]***
2022-04-22T07:49:44.9107864Z ##[debug]***
2022-04-22T07:49:44.9108547Z ##[debug]***
2022-04-22T07:49:44.9109207Z ##[debug]***
2022-04-22T07:49:44.9109797Z ##[debug]***
2022-04-22T07:49:44.9110483Z ##[debug]***
2022-04-22T07:49:44.9111158Z ##[debug]***
2022-04-22T07:49:44.9111812Z ##[debug]***
2022-04-22T07:49:44.9112465Z ##[debug]***
2022-04-22T07:49:44.9112957Z ##[debug]***'
2022-04-22T07:49:44.9113978Z ##[debug]Evaluating: github.token
2022-04-22T07:49:44.9114512Z ##[debug]Evaluating Index:
2022-04-22T07:49:44.9115009Z ##[debug]..Evaluating github:
2022-04-22T07:49:44.9115540Z ##[debug]..=> Object
2022-04-22T07:49:44.9116028Z ##[debug]..Evaluating String:
2022-04-22T07:49:44.9116536Z ##[debug]..=> 'token'
2022-04-22T07:49:44.9117307Z ##[debug]=> '***'
2022-04-22T07:49:44.9117930Z ##[debug]Result: '***'
2022-04-22T07:49:44.9123221Z ##[debug]Loading env
2022-04-22T07:49:44.9130847Z ##[group]Run JamesIves/github-pages-deploy-action@releases/v4
2022-04-22T07:49:44.9131442Z with:
2022-04-22T07:49:44.9131909Z branch: gh-pages
2022-04-22T07:49:44.9132384Z folder: build/doc
2022-04-22T07:49:44.9132889Z target-folder: develop
2022-04-22T07:49:44.9133368Z clean: true
2022-04-22T07:49:44.9134441Z clean-exclude: releases/
2022-04-22T07:49:44.9147558Z ssh-key: ***
2022-04-22T07:49:44.9148418Z token: ***
2022-04-22T07:49:44.9149113Z force: true
2022-04-22T07:49:44.9158706Z ##[endgroup]
2022-04-22T07:49:44.9177097Z ##[command]/usr/bin/docker exec 70afe1b9a4ef88f84d78b2f4e1b8e8412a3ec086338d5414d4864942440c4f31 sh -c "cat /etc/*release | grep ^ID"
2022-04-22T07:49:45.0205408Z ##[debug]ID=ubuntu
2022-04-22T07:49:45.0205926Z ##[debug]ID_LIKE=debian
2022-04-22T07:49:45.0206503Z ##[debug]Running JavaScript Action with default external tool: node12
2022-04-22T07:49:45.2219403Z
2022-04-22T07:49:45.2220423Z ╭━━━╮╭╮╭╮╱╭╮╱╱╭╮╱╱╭━━━╮
2022-04-22T07:49:45.2221366Z ┃╭━╮┣╯╰┫┃╱┃┃╱╱┃┃╱╱┃╭━╮┃
2022-04-22T07:49:45.2221962Z ┃┃╱╰╋╮╭┫╰━╯┣╮╭┫╰━╮┃╰━╯┣━━┳━━┳━━┳━━╮
2022-04-22T07:49:45.2222579Z ┃┃╭━╋┫┃┃╭━╮┃┃┃┃╭╮┃┃╭━━┫╭╮┃╭╮┃┃━┫━━┫
2022-04-22T07:49:45.2223179Z ┃╰┻━┃┃╰┫┃╱┃┃╰╯┃╰╯┃┃┃╱╱┃╭╮┃╰╯┃┃━╋━━┃
2022-04-22T07:49:45.2228864Z ╰━━━┻┻━┻╯╱╰┻━━┻━━╯╰╯╱╱╰╯╰┻━╮┣━━┻━━╯
2022-04-22T07:49:45.2229540Z ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━╯┃
2022-04-22T07:49:45.2230116Z ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━━╯
2022-04-22T07:49:45.2230680Z ╭━━━╮╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╭━━━╮╱╱╭╮
2022-04-22T07:49:45.2231231Z ╰╮╭╮┃╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱┃╭━╮┃╱╭╯╰╮
2022-04-22T07:49:45.2231825Z ╱┃┃┃┣━━┳━━┫┃╭━━┳╮╱╭╮┃┃╱┃┣━┻╮╭╋┳━━┳━╮
2022-04-22T07:49:45.2232426Z ╱┃┃┃┃┃━┫╭╮┃┃┃╭╮┃┃╱┃┃┃╰━╯┃╭━┫┃┣┫╭╮┃╭╮╮
2022-04-22T07:49:45.2233041Z ╭╯╰╯┃┃━┫╰╯┃╰┫╰╯┃╰━╯┃┃╭━╮┃╰━┫╰┫┃╰╯┃┃┃┃
2022-04-22T07:49:45.2233639Z ╰━━━┻━━┫╭━┻━┻━━┻━╮╭╯╰╯╱╰┻━━┻━┻┻━━┻╯╰╯
2022-04-22T07:49:45.2234288Z ╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╭━╯┃
2022-04-22T07:49:45.2234806Z ╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╰━━╯
2022-04-22T07:49:45.2235260Z
2022-04-22T07:49:45.2235502Z
2022-04-22T07:49:45.2235907Z 💖 Support: https://github.com/sponsors/JamesIves
2022-04-22T07:49:45.2236607Z 📣 Maintained by James Ives: https://jamesiv.es
2022-04-22T07:49:45.2236959Z
2022-04-22T07:49:45.2237458Z 🚀 Getting Started Guide: https://github.com/JamesIves/github-pages-deploy-action
2022-04-22T07:49:45.2238495Z ❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
2022-04-22T07:49:45.2239444Z 🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
2022-04-22T07:49:45.2240642Z Checking configuration and starting deployment… 🚦
2022-04-22T07:49:45.2247994Z Configuring SSH client… 🔑
2022-04-22T07:49:45.2427646Z Identity added: (stdin) (tiziano.mueller@chem.uzh.ch)
2022-04-22T07:49:45.2477553Z Deploying using SSH Deploy Key… 🔑
2022-04-22T07:49:45.2481346Z Configuring git…
2022-04-22T07:49:45.2504350Z [command]/usr/bin/git config user.name dev-zero
2022-04-22T07:49:45.2545020Z fatal: not in a git directory
2022-04-22T07:49:45.2589816Z ##[error]There was an error initializing the repository: The process '/usr/bin/git' failed with exit code 128 ❌
2022-04-22T07:49:45.2600603Z ##[notice]Deployment failed! ❌
2022-04-22T07:49:45.2601516Z
2022-04-22T07:49:45.2602605Z ::set-output name=deployment-status::failed
2022-04-22T07:49:45.2605469Z ##[debug]='failed'
2022-04-22T07:49:45.2691401Z ##[debug]Node Action run completed with exit code 1
2022-04-22T07:49:45.2704719Z ##[debug]SSH_AUTH_SOCK='/tmp/ssh-Bl4lC1Ij5PAr/agent.1652'
2022-04-22T07:49:45.2705483Z ##[debug]SSH_AGENT_PID='1653'
2022-04-22T07:49:45.2706031Z ##[debug]deployment_status='failed'
2022-04-22T07:49:45.2710558Z ##[debug]Finishing: Deploy Development Documentation
[...]
Since this action started to fail at the same time when the git CVE fix was pushed, I added the following step before running the gh-deploy-action and it works around the issue:
- name: Configure git to trust the workspace despite the different owner
run:
git config --global --add safe.directory "$GITHUB_WORKSPACE"
See this issue for the fix in actions/checkout, and issue 766 in the same repo for the ongoing discussion about how to fix this in other actions.
Is this still occurring if you update to checkout v3.0.2
?
At any rate, I have a test version of this available here: JamesIves/github-pages-deploy-action/v4-safe-directory
if you'd like to give it a try. If this works I can promote this build once I get back to my computer.
I am still having this same error occur, even when using v4.3.3. Note that it's fatal: not in a git directory
, not fatal: unsafe repository
; I don't know if that makes a difference.
There is a thread on this issue here: #651 with some workarounds. I am going to close the discussion there in favor of this issue.
There is a test version of a fix available here: JamesIves/github-pages-deploy-action@releases/v4-init
which you can point your workflow to. Sadly my time is very limited this week so pushing this over the finish line is going to be difficult. For an example of what this might look like you can click here, the contribution guide will help you get set up if you want to own this. It mostly just needs test coverage and validation.
The interesting thing for my workflow is that I have two checkout
actions running, both of which are checking out into subdirectories of the working directory rather than directly in the working directory. The gh-pages
deploy action is pointed to a subfolder of one of those checkout
directories. I tried adding a working-directory
to the step that does the gh-pages
deploy, but that option is only available for run
steps not uses
steps. I wonder if this action changing the working directory first to the folder
option before running any git actions would resolve this (I had a quick look through the code and couldn't quite be sure if that was the way it was set up). I was also previously using another GitHub Action for this deploy, and switched to this new one as that had also recently started failing.
The action gets the workspace from the runners environment variables, the cwd is set as the second arg of the execute function on every command. As you said the likelihood is that when actions/checkout
initializes using the path
param the git directory is in a sub-folder and not the root of the working directory, in this case it would be similar to the cases where other people aren't running actions/checkout
at all and seeing the same error. In your case specifically this is probably due to an upstream change from actions/checkout
.
Does JamesIves/github-pages-deploy-action@releases/v4-init
work for you? I'd prefer to implement this fix in a way where it doesn't disrupt, or require exceptions if there's an initialization problem or not. For instance you can run git init
in an already established git directory (for cases where actions/checkout initializes this would continue to work), but that alone isn't adequate to resolve this, it seems to require an empty commit, or perhaps even orphan branching, which could result in undesired commits making their way to users deployment branches.
Try one more time? Pushed some changes.
Looks like it's getting closer. Seems to be an order-of-operations error now.
Log
One more try? I omitted the empty commit line so I'm curious if this will work.
Still failing.
[Log] (https://github.com/control4/docs-driverworks-api/runs/6197059489?check_suite_focus=true)
Just for future reference of other people, if your git version is too old (< 2.18
), then the actions/checkout
won't download a local git repo, but instead just the files, which will trigger fatal: not in a git directory
.
I guess a common source of this is using old containers, like based on ubuntu bionic (18.04LTS), which was exactly what happened to me.