Skip to content

Commit

Permalink
fix: configure git for docs push in publish action
Browse files Browse the repository at this point in the history
  • Loading branch information
eykd committed Feb 1, 2024
1 parent 321e173 commit 0474c55
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pypipublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ jobs:
- run: |
poetry install --with=dev
- run: |
# From https://github.com/mhausenblas/mkdocs-deploy-gh-pages/blob/e55ecab6718b449a90ebd4313f1320f9327f1386/action.sh#L35C1-L59C1
if [ -n "${GITHUB_TOKEN}" ]; then
print_info "setup with GITHUB_TOKEN"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_REPOSITORY}.git"
elif [ -n "${PERSONAL_TOKEN}" ]; then
print_info "setup with PERSONAL_TOKEN"
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_REPOSITORY}.git"
else
print_info "no token found; linting"
exec -- mkdocs build --config-file "${CONFIG_FILE}"
fi
# workaround, see https://github.com/actions/checkout/issues/766
git config --global --add safe.directory "$GITHUB_WORKSPACE"
if ! git config --get user.name; then
git config --global user.name "${GITHUB_ACTOR}"
fi
if ! git config --get user.email; then
git config --global user.email "${GITHUB_ACTOR}@users.noreply.${GITHUB_DOMAIN:-"github.com"}"
fi
git remote rm origin
git remote add origin "${remote_repo}"
poetry run mike deploy --push --update-aliases $(poetry version --short|cut -d. -f-2) latest
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

0 comments on commit 0474c55

Please sign in to comment.