You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GH-token无效:Travis部署GitHub Pages失败求助

Troubleshooting Invalid GH-token Error When Deploying to GitHub Pages via Travis CI

Hey there, let's work through this GH-token invalid error you're hitting. I've dealt with similar issues before, so here are the most common fixes to check step by step:

  • Double-check your token's permissions
    Head over to your GitHub account's Settings > Developer settings > Personal access tokens, and find the token you created for Travis. For GitHub Pages deployment, you need at least the repo scope (or public_repo if your repo is public). If the right permissions aren't checked, regenerate a new token with the correct scope.

  • Verify the token is correctly added to Travis
    Log into Travis CI, navigate to your vuecommerce repo's Settings > Environment Variables. Make sure:

    • The variable name matches what's in your .travis.yml (most often GH_TOKEN)
    • The token value is pasted exactly—no extra spaces or line breaks. Try re-pasting the token to rule out typos.
  • Test the token's validity locally
    Run this curl command in your terminal (replace YOUR_GH_TOKEN with your actual token) to confirm the token works on its own:

    curl -H "Authorization: token YOUR_GH_TOKEN" https://api.github.com/user
    

    If you still get a 401 error here, your token is either expired (if you set an expiry date when creating it) or revoked. You'll need to generate a brand new token.

  • Audit your .travis.yml config
    Make sure your deploy block is correctly referencing the environment variable, not hardcoding the token. A valid config should look something like this:

    deploy:
      provider: pages
      skip_cleanup: true
      github_token: $GH_TOKEN
      local_dir: dist # Update this to your actual build output folder
      on:
        branch: master # Or your deployment branch, like main
    

    Hardcoding tokens in the config will get them invalidated by GitHub automatically, so always use environment variables.

  • Confirm repository access
    Ensure the token was created by a GitHub account that has write access to the vuecommerce repo. If it's an organization repo, double-check that your account has the necessary permissions on the repo, and the token includes any required organization scopes.

内容的提问来源于stack exchange,提问作者Harry Nguyen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:04:01