Skip to content
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

gh-deploy doesn't work as expected #2447

Closed
almostengr opened this issue Jun 8, 2021 · 12 comments
Closed

gh-deploy doesn't work as expected #2447

almostengr opened this issue Jun 8, 2021 · 12 comments

Comments

@almostengr
Copy link

almostengr commented Jun 8, 2021

Before recent updates, gh-deploy would work fine. Since the latest update, it does not work.

The output in the console shows that it should have deployed. However when I check the corresponding git branch on Github, it does not show that the command work. I've tried using gh-deploy with other branches, and those branches did not get to Github either.

I see that an update in commit 2688a6d was made regarding the gh-deploy command. Perhaps this change could be the culprit?

Below is the console output from my computer where the command should have pushed the build to Github, but it did not.

almostengineer@aeoffice:~/almostengrwebsite$ /usr/bin/python3 -m mkdocs gh-deploy -f Almostengr.AlmostengrWebsite/mkdocs.yml -b website 
INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /home/almostengineer/almostengrwebsite/Almostengr.AlmostengrWebsite/site
INFO     -  Documentation built in 4.36 seconds
INFO     -  Copying '/home/almostengineer/almostengrwebsite/Almostengr.AlmostengrWebsite/site' to 'website' branch and pushing to GitHub.
INFO     -  Your documentation should shortly be available at: https://almostengr.github.io/almostengrwebsite/

The current PIP packages that I have installed are

pip
setuptools
mkdocs
mkdocs-minify-plugin

and I did upgrade to the latest version of Python and the above mentioned packages before filing this bug.

EDIT: Including link to workflow file
https://github.com/almostengr/almostengrwebsite/actions/runs/901490280/workflow

@luolingchun
Copy link

I had the same problem in GitHub action.

@nemchik
Copy link

nemchik commented Jun 8, 2021

I seem to be having a similar issue, but I'm getting a different output.
Using GitHub Actions, here is my workflow file https://github.com/nemchik/nemchik/blob/master/.github/workflows/deploy.yml
Here are (one of many) failing logs since upgrading from 1.1.2 to 1.2 https://github.com/nemchik/nemchik/runs/2774724580
Here is the specific excerpt that seems relevant to me:

2021-06-08T14:14:28.2855939Z ##[group]Run mkdocs gh-deploy --force
2021-06-08T14:14:28.2856606Z �[36;1mmkdocs gh-deploy --force�[0m
2021-06-08T14:14:28.2898882Z shell: /usr/bin/bash -e {0}
2021-06-08T14:14:28.2899289Z env:
2021-06-08T14:14:28.2899818Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2021-06-08T14:14:28.2900535Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2021-06-08T14:14:28.2901060Z ##[endgroup]
2021-06-08T14:14:28.5947430Z INFO     -  Cleaning site directory
2021-06-08T14:14:28.5948353Z INFO     -  Building documentation to directory: /home/runner/work/nemchik/nemchik/site
2021-06-08T14:14:28.7987593Z INFO     -  Documentation built in 0.20 seconds
2021-06-08T14:14:28.8051563Z �[33mWARNING  -  �[0mVersion check skipped: No version specified in previous deployment.
2021-06-08T14:14:28.8078397Z INFO     -  Copying '/home/runner/work/nemchik/nemchik/site' to 'gh-pages' branch and pushing to GitHub.
2021-06-08T14:14:29.2414729Z To https://github.com/nemchik/nemchik
2021-06-08T14:14:29.2418541Z  ! [rejected]        gh-pages -> gh-pages (fetch first)
2021-06-08T14:14:29.2419581Z error: failed to push some refs to 'https://github.com/nemchik/nemchik'
2021-06-08T14:14:29.2434783Z hint: Updates were rejected because the remote contains work that you do
2021-06-08T14:14:29.2444456Z hint: not have locally. This is usually caused by another repository pushing
2021-06-08T14:14:29.2445601Z hint: to the same ref. You may want to first integrate the remote changes
2021-06-08T14:14:29.2446741Z hint: (e.g., 'git pull ...') before pushing again.
2021-06-08T14:14:29.2447665Z hint: See the 'Note about fast-forwards' in 'git push --help' for details.
2021-06-08T14:14:29.2448371Z Traceback (most recent call last):
2021-06-08T14:14:29.2450004Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/bin/mkdocs", line 8, in <module>
2021-06-08T14:14:29.2450703Z     sys.exit(cli())
2021-06-08T14:14:29.2451828Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
2021-06-08T14:14:29.2452711Z     return self.main(*args, **kwargs)
2021-06-08T14:14:29.2453823Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1062, in main
2021-06-08T14:14:29.2456956Z     rv = self.invoke(ctx)
2021-06-08T14:14:29.2458112Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
2021-06-08T14:14:29.2459137Z     return _process_result(sub_ctx.command.invoke(sub_ctx))
2021-06-08T14:14:29.2460227Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
2021-06-08T14:14:29.2461059Z     return ctx.invoke(self.callback, **ctx.params)
2021-06-08T14:14:29.2462109Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 763, in invoke
2021-06-08T14:14:29.2462905Z     return __callback(*args, **kwargs)
2021-06-08T14:14:29.2463950Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/mkdocs/__main__.py", line 205, in gh_deploy_command
2021-06-08T14:14:29.2464990Z     gh_deploy.gh_deploy(cfg, message=message, force=force, ignore_version=ignore_version, shell=shell)
2021-06-08T14:14:29.2466298Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/mkdocs/commands/gh_deploy.py", line 108, in gh_deploy
2021-06-08T14:14:29.2467089Z     ghp_import.ghp_import(
2021-06-08T14:14:29.2468078Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ghp_import.py", line 263, in ghp_import
2021-06-08T14:14:29.2469142Z     git.check_call('push', opts['remote'], opts['branch'])
2021-06-08T14:14:29.2470218Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ghp_import.py", line 121, in check_call
2021-06-08T14:14:29.2471204Z     sp.check_call(['git'] + list(args), **kwargs)
2021-06-08T14:14:29.2472074Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/subprocess.py", line 373, in check_call
2021-06-08T14:14:29.2520031Z     raise CalledProcessError(retcode, cmd)
2021-06-08T14:14:29.2521753Z subprocess.CalledProcessError: Command '['git', 'push', 'origin', 'gh-pages']' returned non-zero exit status 1.
2021-06-08T14:14:29.2856707Z ##[error]Process completed with exit code 1.

It seems to me like it's ignoring that I have the --force flag.

This may be a different problem than what @almostengr has described and I can open a new issue for it if required.

@MichaelCurrin
Copy link

MichaelCurrin commented Jun 8, 2021

I had the same issue where force flag appears ignored and that I get the pull in remote changes error. Caused by me making a local deploy - which is supposed to be overcome with force.

I deleted the remote branch gh-pages and reran the GH Actions job and then the job succeeded (there was no branch discrepancy to cause the error).

Then I pushed another commit (without doing a deploy local) and then that caused the failing job again. :/

https://github.com/MichaelCurrin/mkdocs-quickstart/runs/2775959629?check_suite_focus=true

@almostengr
Copy link
Author

I seem to be having a similar issue, but I'm getting a different output.
Using GitHub Actions, here is my workflow file https://github.com/nemchik/nemchik/blob/master/.github/workflows/deploy.yml
Here are (one of many) failing logs since upgrading from 1.1.2 to 1.2 https://github.com/nemchik/nemchik/runs/2774724580
Here is the specific excerpt that seems relevant to me:

2021-06-08T14:14:28.2855939Z ##[group]Run mkdocs gh-deploy --force
2021-06-08T14:14:28.2856606Z �[36;1mmkdocs gh-deploy --force�[0m
2021-06-08T14:14:28.2898882Z shell: /usr/bin/bash -e {0}
2021-06-08T14:14:28.2899289Z env:
2021-06-08T14:14:28.2899818Z   pythonLocation: /opt/hostedtoolcache/Python/3.9.5/x64
2021-06-08T14:14:28.2900535Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.5/x64/lib
2021-06-08T14:14:28.2901060Z ##[endgroup]
2021-06-08T14:14:28.5947430Z INFO     -  Cleaning site directory
2021-06-08T14:14:28.5948353Z INFO     -  Building documentation to directory: /home/runner/work/nemchik/nemchik/site
2021-06-08T14:14:28.7987593Z INFO     -  Documentation built in 0.20 seconds
2021-06-08T14:14:28.8051563Z �[33mWARNING  -  �[0mVersion check skipped: No version specified in previous deployment.
2021-06-08T14:14:28.8078397Z INFO     -  Copying '/home/runner/work/nemchik/nemchik/site' to 'gh-pages' branch and pushing to GitHub.
2021-06-08T14:14:29.2414729Z To https://github.com/nemchik/nemchik
2021-06-08T14:14:29.2418541Z  ! [rejected]        gh-pages -> gh-pages (fetch first)
2021-06-08T14:14:29.2419581Z error: failed to push some refs to 'https://github.com/nemchik/nemchik'
2021-06-08T14:14:29.2434783Z hint: Updates were rejected because the remote contains work that you do
2021-06-08T14:14:29.2444456Z hint: not have locally. This is usually caused by another repository pushing
2021-06-08T14:14:29.2445601Z hint: to the same ref. You may want to first integrate the remote changes
2021-06-08T14:14:29.2446741Z hint: (e.g., 'git pull ...') before pushing again.
2021-06-08T14:14:29.2447665Z hint: See the 'Note about fast-forwards' in 'git push --help' for details.
2021-06-08T14:14:29.2448371Z Traceback (most recent call last):
2021-06-08T14:14:29.2450004Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/bin/mkdocs", line 8, in <module>
2021-06-08T14:14:29.2450703Z     sys.exit(cli())
2021-06-08T14:14:29.2451828Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1137, in __call__
2021-06-08T14:14:29.2452711Z     return self.main(*args, **kwargs)
2021-06-08T14:14:29.2453823Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1062, in main
2021-06-08T14:14:29.2456956Z     rv = self.invoke(ctx)
2021-06-08T14:14:29.2458112Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1668, in invoke
2021-06-08T14:14:29.2459137Z     return _process_result(sub_ctx.command.invoke(sub_ctx))
2021-06-08T14:14:29.2460227Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
2021-06-08T14:14:29.2461059Z     return ctx.invoke(self.callback, **ctx.params)
2021-06-08T14:14:29.2462109Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/click/core.py", line 763, in invoke
2021-06-08T14:14:29.2462905Z     return __callback(*args, **kwargs)
2021-06-08T14:14:29.2463950Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/mkdocs/__main__.py", line 205, in gh_deploy_command
2021-06-08T14:14:29.2464990Z     gh_deploy.gh_deploy(cfg, message=message, force=force, ignore_version=ignore_version, shell=shell)
2021-06-08T14:14:29.2466298Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/mkdocs/commands/gh_deploy.py", line 108, in gh_deploy
2021-06-08T14:14:29.2467089Z     ghp_import.ghp_import(
2021-06-08T14:14:29.2468078Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ghp_import.py", line 263, in ghp_import
2021-06-08T14:14:29.2469142Z     git.check_call('push', opts['remote'], opts['branch'])
2021-06-08T14:14:29.2470218Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/site-packages/ghp_import.py", line 121, in check_call
2021-06-08T14:14:29.2471204Z     sp.check_call(['git'] + list(args), **kwargs)
2021-06-08T14:14:29.2472074Z   File "/opt/hostedtoolcache/Python/3.9.5/x64/lib/python3.9/subprocess.py", line 373, in check_call
2021-06-08T14:14:29.2520031Z     raise CalledProcessError(retcode, cmd)
2021-06-08T14:14:29.2521753Z subprocess.CalledProcessError: Command '['git', 'push', 'origin', 'gh-pages']' returned non-zero exit status 1.
2021-06-08T14:14:29.2856707Z ##[error]Process completed with exit code 1.

It seems to me like it's ignoring that I have the --force flag.

This may be a different problem than what @almostengr has described and I can open a new issue for it if required.

Your issue seems to be a bit different. However the fact that you are getting Python errors in your logs is also concerning and telling of what the origin of the problem could be

@andylwelch
Copy link

I too have encountered this issue. gh-deploy does not force push anymore

@andylwelch
Copy link

Here's a workaround for your deploy.yml to force mkdocs version 1.1.2

...
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: 3.x
      - run: pip install mkdocs==1.1.2
      - run: pip install mkdocs-material
      - run: mkdocs gh-deploy --force

@npucino
Copy link

npucino commented Jun 9, 2021

I "solved" this issue by forcing the use of mkdocs==1.1.2. This restored the expected behaviour. Waiting to understand how to properly use mkdocs 1.2.

@MichaelCurrin
Copy link

MichaelCurrin commented Jun 9, 2021

Thanks, works for me - run 👍

I set mine to have the same ~=1.1 as before (which is 1.1, 1.2, 1.3 etc), but I added a part to exclude 1.2 specifically.

requirements.txt

BW I recommend using requirements file so you can use the same version locally and in GH Actions. Defining only in your workflow as - run: pip install mkdocs==1.1.2 is not code you can run locally directly as it is in a YAML file.

@waylan
Copy link
Member

waylan commented Jun 9, 2021

Yes, this is a known issue, which has been fixed in #2444 and will be available in version 1.2.1 when it is released. In the meantime you can either use --force or stay on 1.1.2. Sorry for the inconvenience.

I'm closing this as a duplicate of #2444.

@waylan waylan closed this as completed Jun 9, 2021
@MichaelCurrin
Copy link

Thanks for the info. @waylan

Yes agree with staying on 1.1.2.

Note that using --force is not a fix here, as the error I had and someone else had was caused by indeed including the force flag, but it not having an effect and the build complaining about differences on the remote.

It seems to me like it's ignoring that I have the --force flag. comment

@waylan
Copy link
Member

waylan commented Jun 9, 2021

FYI, version 1.2.1 has been released.

@nemchik
Copy link

nemchik commented Jun 9, 2021

Seems to have worked for me! Thanks for the quick fix!

stefnestor added a commit to stefnestor/demo_mkdocs that referenced this issue Sep 18, 2021
cruizen added a commit to arlonproj/arlon that referenced this issue Aug 29, 2022
Update the mkdocs engine to the latest patch 1.3.1 
We are currently seeing an issue similar to mkdocs/mkdocs#2447 i.e. deployment fails for some PRs involving updates to docs 
Updating mkdocs might fix the issue.
cruizen added a commit to arlonproj/arlon that referenced this issue Aug 29, 2022
Update the mkdocs engine to the latest patch 1.3.1 
We are currently seeing an issue similar to mkdocs/mkdocs#2447 i.e. deployment fails for some PRs involving updates to docs 
Updating mkdocs might fix the issue.
cruizen added a commit to arlonproj/arlon that referenced this issue Dec 16, 2022
Update the mkdocs engine to the latest patch 1.3.1 
We are currently seeing an issue similar to mkdocs/mkdocs#2447 i.e. deployment fails for some PRs involving updates to docs 
Updating mkdocs might fix the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants