tschaub / gh-pages

General purpose task for publishing files to a gh-pages branch on GitHub
https://www.npmjs.com/package/gh-pages
MIT License
3.22k stars 190 forks source link

use of GH_TOKEN in .env file with gh-pages -d #406

Open blurymind opened 3 years ago

blurymind commented 3 years ago

As you probably know github no longer accepts passwords, which completely breaks the use of gh-pages -d dist

Yet gh-pages will still ask you to enter a username and a password,only to then give you an error to tell you this no longer can be accepted. It seems like a bug now.

My question here is this - if say I have a .env file in the same folder as the package.json with that gh-pages -d dist script, why can't we have gh-pages automatically pick my token from the env file and just do its job?

It doesnt seem to have anything in place that would let me continue doing it from package.json, so can you point me to some example? A script perhaps that uses a token?

This doesnt seem to work

ghpages.publish('dist', {
  repo: 'https://' + process.env.GH_TOKEN + '@github.com/user/private-repo.git',
  silent: true
}, callback);

you get

Error: Remote url mismatch.  Got "https://github.com/blurymind/tilemap-editor.git" but expected "https://ghp_xxxxxxxxxxqRNJ7kpEM5lbCI8kDtU4HssCG@github.com/blurymind/tilemap-editor.git" in /home/fox/DEV/tilemap-editor/node_modules/.cache/gh-pages/github.com!blurymind!tilemap-editor.git.  Try running the `gh-pages-clean` script first.
    at /home/fox/DEV/tilemap-editor/node_modules/gh-pages/lib/index.js:130:19

Process finished with exit code 0

this is the deploy script I tried (process.env.GH_TOKEN was not getting picked from the .env file which is another issue)

const ghpages = require('gh-pages');

//https://github.com/blurymind/tilemap-editor.git
ghpages.publish('.', {
    repo: 'https://' + "ghp_xxxxxxxxxxxxxxxkpEM5lbCI8kDtU4HssCG" + '@github.com/blurymind/tilemap-editor.git',
    // silent: true
}, console.log);

I use gh-pages for https://github.com/blurymind/tilemap-editor https://github.com/YarnSpinnerTool/YarnEditor

the deployment for both broke

tordans commented 2 years ago

@blurymind JFYI and maybe you have something to add to https://github.com/tschaub/gh-pages/issues/413