Jekyll, github and Travis ... for dummies

Hello,
I am a little bit lost with jekyll, github and travis …
I developp my website on my own machine and I deploy it on github (gh-pages).
As most of plugins are disabled on github, a guy suggested to use travis ci.

  • I created an account on travis ci

  • I created a file, .travis.yml, on my machine

  • I wrote this:
    language: ruby
    cache: bundler
    sudo: false
    script: bundle exec jekyll build
    after_sucess:

    • chmod 777 deploy.sh
    • ./deploy.sh
  • I created a token in github for travis

  • I past this token in my travis desktop > myrepository > setting > environment variable

  • I named it GH_TOKEN

  • I created and filled deploy.sh:
    #!/bin/sh
    cd _site
    git init
    git config user.name “Travis CI”
    git config user.email “travis@travis-ci.org
    git add --all
    git commit --message “Auto deploy from Travis CI build $TRAVIS_BUILD_NUMBER”
    git remote add deploy https://$GH_TOKEN@github.com/my_name/my_repository.github.io.git >/dev/null 2>&1
    git push --force deploy gh-pages >/dev/null 2>&1

  • I made a modification in my website on my machine

  • I deployed with the following commands:
    git add .
    git commit -m “version x.y.z”
    git push origin gh-pages

  • on my travis desktop, for my repository: nil !
    I have the message “no buils for this repository”

why Travis didn’t receive data ?
what is missing in my procedure ?

I also tried:
more options
trigger custom build with branch=gh-pages

My request was rejected
In the requests menu, I have for each line:
github pages branch not included via configuration

Commit the .travis files to your main branch also (probably called master, depending on when in time you read this)

Travis only uses the configs from the primary branch because of forks and things could expose or trigger things against someone’s will.

Side my machine, the site is in the gh-pages branch;
Side github, the site is deplayed in the gh-pages branch;
Don’t say why, I followed several tutorials …
Side github, the master branch is empty: if I understood, this is the reason why Travis has no builds.

What can I do now ?

  1. Push from my machine to the master branch instead of the gh-pages branch
    or
  2. Side github, move the contents of gh-pages branch in the master branch

In both cases, I don’t know the procedure. If you could light me !
In other words, how to clean the situation ?
rgds,

Delete your gh-pages branch of github or delete the contents locally and commit and push the branch.

I’m not familiar with Travis but check the deploy automation section of docs https://jekyllrb.com/docs/deployment/automated/

If you follow the Github Actions flow there. you can deploy to GH pages using a copied workflow file of about 15 lines. (Use GITHUB_TOKEN in place of JEKYLL_PAT.)

That’s a lot simpler than running your own script and running it locally. And you can use any gems. There is a live example at the bottom of the GH Actions doc.

Also Netlify is a great alternative for building and serving your site.

Use whatever gems you want in Gemfile
And build is as simple as

build: jekyll build

Note the GH Actions flow uses gh-pages branch to serve but Netlify stores build result on its own side so doesn’t need gh-pages branch