Is a personal access token needed?

I have the following Action set up in order to push files to the GitHub Pages branch using MkDocs.

The question I now have is, if the GH_TOKEN, which is a Personal Access Token, is required for this to work, or if I can replace it with something else (or remove it altogether).

The YAML file I have setup

name: Deploy Site

    - 'docs/**'
    - '**.yml'
    - 'theme/**'
    - master

    runs-on: [ubuntu-latest]
    - uses: actions/checkout@v2
    - name: Set up Python 3.7
      uses: actions/setup-python@v1
        python-version: 3.7
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip setuptools
        python -m pip install -r requirements.txt # File only has mkdocs-material >= 5.0.0
    - name: Deploy Files
      run: |
        git config "github-actions[bot]" # I use the GitHub Actions bot here.
        git config "41898282+github-actions[bot]"
        git remote add gh-token "https://${{ secrets.GH_TOKEN}}" # Example
        git fetch gh-token && git fetch gh-token gh-pages:gh-pages
        python -m mkdocs gh-deploy --clean --remote-name gh-token
        git push gh-token gh-pages

Hi @andre601 ,

If you’re pushing commit to ‘gh-pages’ branch in same repository, you can skip token:

git remote add gh-token ""

This is due to ‘actions/checkout’ will automatically add GITHUB_TOKEN to later git operations, and the token has write permission to current repo.

If you push commit to another repository, personal access token is needed. Code sample as below:

git remote add gh-token "https://weide-zhou:${{ secrets.PAT1 }}"


1 Like


It works without any issues.