Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Automatically update repo details #75

Closed
monteva opened this issue Jun 10, 2019 · 16 comments
Closed

Automatically update repo details #75

monteva opened this issue Jun 10, 2019 · 16 comments
Labels
help wanted Extra attention is needed

Comments

@monteva
Copy link

monteva commented Jun 10, 2019

What feature should be added?

Automatically updating stars, forks, and other details.

Why should this feature be added?

To do gitfolio update, you need to have access to your PC, without which you cannot update your website. It will also reduce the number of times we need to manually update the website.

@boxdox
Copy link

boxdox commented Jun 21, 2019

or you can setup a CI system to do it for you.

@monteva
Copy link
Author

monteva commented Jun 23, 2019

How do I do that? Sorry I am new to programming

@boxdox
Copy link

boxdox commented Jun 24, 2019

  1. You can create a node JS project and add 'gitfolio' as dependency.
  2. Next create a build script in package.json for building your site.
  3. Deploy your project to github.
  4. Sign up for netlify and connect it to github.
  5. In netlify's build command, type the command you created in package.json (for ex: npm build)
  6. Now your website will be built whenever you push to the repository.

For automatically updating:

  1. Create a webhook for triggering deploy in netlify.
  2. Use a cron job (if you have a server) or use IFTTT to trigger the webhook as per your time requirement.

For creating the node JS project, you can have a look at my repo

@monteva
Copy link
Author

monteva commented Jul 2, 2019

Hi,

Firstly, thank you so much for taking out time to write such a neat guide. It really did help a lot.

I had one question, so I've tried to tinker with things and somehow I've made something. However, my website has been deployed on netlify and not on github pages. Is there a way by which I can deploy it on github-pages (aka - monteva.github.io)?

@boxdox
Copy link

boxdox commented Jul 3, 2019

The reason I made you choose Netlify was because it has hosting as well as CI built in.

If you want to publish your site to GitHub pages, you need another CI tool that can generate your site and push it to your specified repository.

I can recommend you to read this article and change your config file accordingly: https://takuti.me/note/travis-gh-pages-deployment/

@imfunniee
Copy link
Owner

imfunniee commented Jul 3, 2019

ye use @boxdox's method 👌

@monteva
Copy link
Author

monteva commented Jul 3, 2019

@boxdox Thanks a lot for the help yet again. I've set up Travis CI and while I am able to install gitfolio, when I run gitfolio build monteva, it says:

gitfolio: command not found
The command "gitfolio build monteva" exited with 127.

If I replace gitfolio build monteva with npm run-script build in my travis config file, I get:

> gitfolio build monteva
/home/travis/build/monteva/monteva.github.io/node_modules/gitfolio/populate.js:13
    var pattern = /(?<=:\s*).*?(?=\s*:)/gs
                  ^
SyntaxError: Invalid regular expression flags
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/travis/build/monteva/monteva.github.io/node_modules/gitfolio/build.js:9:24)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Module.require (module.js:579:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! monteva.github.io@1.0.0 build: `gitfolio build monteva`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the monteva.github.io@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2019-07-03T22_48_22_914Z-debug.log
The command "npm run-script build" failed and exited with 1 during .

However, my website gets built on Netlify everytime. What am I doing wrong? Sorry for pestering you but it'd be great if you could help me out. Cheers!

@imfunniee Could you please re-open this till I manage to successfully automate my website?

@imfunniee imfunniee reopened this Jul 4, 2019
@imfunniee imfunniee added the help wanted Extra attention is needed label Jul 4, 2019
@boxdox
Copy link

boxdox commented Jul 4, 2019

If you head over to your Travis CI log page, you can see that the language is currently set to Ruby. You need to specify the language at the top of your travis-ci config file.

language: node_js
node_js:
  - "10" # This is the node js version

before_script:
  - npm install

script:
  - npm run start

deploy:
  provider: pages
  skip_cleanup: true
  github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
  keep_history: true
  local_dir: dist
  on:
    branch: master

This config should be sufficient. Also, you get the benefits of cron jobs in travis ci, so you can let the website update automatically.

@monteva
Copy link
Author

monteva commented Jul 5, 2019

With the below travis config, I managed to generate the HTML/CSS files.

language: node_js
node_js:
  - "10" # This is the node js version

before_script:
  - npm i gitfolio -g

script:
  - gitfolio build monteva
    
deploy:
  provider: pages
  skip_cleanup: true
  github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
  keep_history: true
#  local_dir: dist
  on:
    branch: master
  target_branch: master

Since the files are built in the dist folder, I need to uncomment the local_dir: dist part. However, by doing so, although my page gets deployed properly, my files (package.json, README.me, etc.) get erased and only the dist folder contents remain.

With # local_dir: dist, here is how my repo looks.

With local_dir: dist, here is how my repo looks.

What am I doing wrong?

@boxdox
Copy link

boxdox commented Jul 5, 2019

At this point, I would ask you to RTFM. You're just collecting parts of code and calling it a day. You need to know how Git works and how CI like Travis integrates with Github. You should always read the documentation.

Coming back to your problem. Whenever you want Github pages to show your site, you need to specify the 'branch' from which github pages will serve your site. Currently, your package.json and .travis.yml sit in the 'master' branch. In your travis config, on the last line, you have asked travis to push data to 'master' again, essentially overwriting your previous code. Remove that line. Travis will automatically push to 'gh-pages' branch (which is default for github pages branch, else you can change in repo settings).

Also, you need the local_dir option, otherwise travis will copy the dist folder, but we need travis to push contents of directory, not the directory itself, so leave that option uncommented.

Read the travis docs for understanding other options.

@satishbabariya
Copy link

here is my own automation for this https://github.com/satishbabariya/satishbabariya.github.io

@boxdox
Copy link

boxdox commented Jul 6, 2019

here is my own automation for this https://github.com/satishbabariya/satishbabariya.github.io

What you're doing is: pushing to master, overwriting stuff and then just copying project files back. This is not a good practice and defeats the purpose of using a vcs, not to mention hacky.

Also, if you wish to go with what you're doing, why run gitfolio build everytime to update the site, when there's gitfolio update available?

@satishbabariya
Copy link

@boxdox yeah sure

@imfunniee
Copy link
Owner

can we close it now?

@boxdox
Copy link

boxdox commented Jul 18, 2019

@imfunniee Yeah, I believe the issue is resolved

@imfunniee
Copy link
Owner

cool

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants