-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GitHub Actions deployment error: "Git push failed" #4336
Comments
I think this happens because I set
I also noticed that the Deploy Key has "never been used": Here's the "Secrets" Page: Do I have to set anything in "Environments"? |
Why does it even try to git clone again? When this code runs it already is in the git repo... |
can you try the new workflow introduced by this PR? I'm not too familiar with GH action, would have to inspect the code. more carefully to understand this problem |
@armano2 I'm pretty sure that won't work as I have already tried that before. I will try again later in case I missed anything. @slorber so that's just moving the ssh-agent step into a dedicated action right? I have currently got it working like this: gh-release:
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Add key to allow access to repository
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
cat <<EOT >> ~/.ssh/config
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa
EOT
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore node_modules from cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Release to GitHub Pages
env:
USE_SSH: true
GIT_USER: git
CURRENT_BRANCH: main
DEPLOYMENT_BRANCH: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "gh-actions"
yarn install --frozen-lockfile
cd docs
yarn install --frozen-lockfile
yarn deploy I'm not sure if that's the best, fastest or safest way, but it works. I'll try to remove all of the SSH stuff so I don't need to worry about the private/public key+secret and just try to use checkout@v2 like @armano2 commented. |
@armano2 okay so I just tried it like this: gh-release:
if: github.event_name != 'pull_request'
name: Build & Release Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Restore node_modules from cache
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Release to GitHub Pages
env:
USE_SSH: true
GIT_USER: github-actions
CURRENT_BRANCH: main
DEPLOYMENT_BRANCH: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
run: |
date > generated.txt
git config user.name github-actions
git config user.email [email protected]
yarn install --frozen-lockfile
cd docs
yarn install --frozen-lockfile
yarn deploy and it did not work. It fails at git clone again: And if I set |
The checkout action default is a shallow clone of the commit. You may need to pull the full history to properly be in sync when doing a push. - uses: actions/checkout@v2
with:
fetch-depth: 0 Alternatively, as I have noticed (with a different deployment approach), Anyway, I started out with the approach that Docusaurus originally documented and found it over-complicated for deploying Github Pages vs other platforms. You can use a Github Action for deployment like this (no SSH keys required): - name: 'Your build steps'
run: |
date > generated.txt
yarn install --frozen-lockfile
cd docs
yarn install --frozen-lockfile
yarn build
- name: 'Deploy to Github Pages'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
user_name: 'github-actions[bot]'
user_email: '41898282+github-actions[bot]@users.noreply.github.com' Note I changed UPDATE: Full workflow example is available via this PR, it presently has plenty of inline comments to clarify anything about the workflow. |
🐛 Bug Report
I am trying to use GitHub actions to automatically build my documentation from the
main
branch (docs/
folder) and deploy it to thegh-pages
branch.I've followed the official guide, but can't seem to get it working.
This is my GitHub Action:
Have you read the Contributing Guidelines on issues?
yea
Your Environment
Reproducible Demo
See my repo, especially the docusaurus config file and the github action.
And here's the log output from the GitHub action.
Note that it does work if I run it locally, so I'm guessing something in the action isn't correctly configured/authenticated...
The text was updated successfully, but these errors were encountered: