jimporter / mike

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

Cannot get mike to work with protected branches #143

Closed karl-johan-grahn closed 1 year ago

karl-johan-grahn commented 1 year ago

We use GitHub protected branches to limit the ability to modify gh-pages and pull-request-deployments to a service account in the GitHub Actions workflow.

The one and only rule that is used for the gh-pages and pull-request-deployments branch is the Restrict who can push to matching branches setting, which is set to the service account.

We configure git:

git config --local user.email "<email>"
git config --local user.name "<github username>"

When the workflow then runs mike deploy --push -b pull-request-deployments $HEAD_REF we get:

error: failed to push branch pull-request-deployments to origin: "fatal: could not read Username for 'https://github.com/': No such device or address"

jimporter commented 1 year ago

Can you provide the full CI configuration and a link to the logs for the failed action?

karl-johan-grahn commented 1 year ago

Resolved it by persisting credentials and using token for git authentication. Template: https://github.com/stakater/.github/blob/main/.github/workflows/pull_request_versioned_doc.yaml

Working example: https://github.com/stakater/test-doc-versioning