jimporter / mike

Manage multiple versions of your MkDocs-powered documentation via Git
BSD 3-Clause "New" or "Revised" License
534 stars 47 forks source link

`origin` always used as upstream? #62

Closed marc0olo closed 3 years ago

marc0olo commented 3 years ago

I got really confused today. may it be the case that origin is currently always used es default upstream by mike? IMO this needs to be changed to point to the "locally" defined upstream.

would be nice to get some clarification and potentially also a fix here.

jimporter commented 3 years ago

For consistency, mike uses the same logic as MkDocs: the remote is specified in remote_name in mkdocs.yml, defaulting to origin. See here for docs: https://www.mkdocs.org/user-guide/configuration/#remote_name

marc0olo commented 3 years ago

makes sense and confirms the statement that most of the time the problem is in front of the desktop 😄

marc0olo commented 3 years ago

seems like I am still struggling a bit with that. the thing is I want to set up a github action that handles the deployments and independent from that I need to be able to perform certain commands locally (e.g. I don't want to set a default-branch each time the github action runs)

so I changed the remote_name now in the mkdocs yml to point to the correct remote:

repo_url: 'https://github.com/aeternity/aepp-sdk-js'
remote_name: marc0olo

extra:
  version:
    provider: mike

here the output in my shell:

marc0olo@DESKTOP-B1QLEDL:~/git/aeternity/aepp-sdk-js$ git remote
marc0olo
origin
marc0olo@DESKTOP-B1QLEDL:~/git/aeternity/aepp-sdk-js$ mike list
warning: gh-pages is unrelated to marc0olo/gh-pages
  Pass --ignore to ignore this or --rebase to rebase onto remote

I definitely have an active deployment on the gh-pages branch of the remote marc0olo: image

is there anything I am doing wrong? I guess the command should list sth. - I want to set the default branch independent from the github action

marc0olo commented 3 years ago

this is not necessarily related to that but I am struggling to deploy changes with github actions generally and wondering how to achieve that without getting the following error:

error: failed to push branch gh-pages to origin: "To https://github.com/marc0olo/aepp-sdk-js
 ! [rejected]        gh-pages -> gh-pages (fetch first)
error: failed to push some refs to 'https://github.com/marc0olo/aepp-sdk-js'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details."
Error: Process completed with exit code 1.

@jimporter do you have an idea how to fix this specifically? I am not sure what needs to be done here. I can "fix" this by providing --force as option. but in this case I would lose the old doc versions. wondering that nobody else faced that issue yet. probably it's just a small adjustion I need to do.

gh-action looks like this right now:

name: Publish develop docs
on:
  push:
    branches: ['develop', 'docs-improvements']

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: 3.8
      - uses: actions/cache@v2
        with:
          path: ~/.cache/pip3
          key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.txt') }}
      - run: pip3 install -r docs/requirements.txt
      - run: git config --global user.email "github-action@users.noreply.github.com"
      - run: git config --global user.name "GitHub Action"
      - run: mike deploy --push develop
jimporter commented 3 years ago

That looks like #60. The short version is that actions/checkout makes a shallow clone, so when mike deploy generates a new commit, it thinks gh-pages is a fresh, empty branch. The easiest way I know of to fix this is:

uses: actions/checkout@v2
with:
  fetch-depth: 0 # fetch all commits/branches

There's probably a better way, but I need to test things out to be sure, which is why it's not in the README yet. ;)

marc0olo commented 3 years ago

That looks like #60. The short version is that actions/checkout makes a shallow clone, so when mike deploy generates a new commit, it thinks gh-pages is a fresh, empty branch. The easiest way I know of to fix this is:

uses: actions/checkout@v2
with:
  fetch-depth: 0 # fetch all commits/branches

There's probably a better way, but I need to test things out to be sure, which is why it's not in the README yet. ;)

thanks, I just tested this as you posted 😄 seems to work

marc0olo commented 3 years ago

I now use origin and don't bother about another remote_name. can use it like I need to. maybe I will revisit this topic again in the future. not sure if it was on my end or if there is another issue.

closing this now. thanks @jimporter !