I'm trying to deploy an User github page only after the execution of all the Travis tests.
However, User pages must be built from the master branch and I need it to be built from the gh-pages if I want Travis to deploy once the tests passed.
The .travis.yml is:
language: node_js
node_js:
- "8.1"
sudo: false
before_install:
- rvm install 2.2.2
- ./tool/before_install.sh
script: ./tool/travis.sh
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure
keep-history: true
on:
branch: master
This configuration file works fine when the gh-pages branch is the one the github page is built from, but when I switch my github page to an User page, I can't choose the gh-pages branch anymore, as shown here:
I tried to change the .travis.yml file:
language: node_js
node_js:
- "8.1"
sudo: false
before_install:
- rvm install 2.2.2
- ./tool/before_install.sh
script: ./tool/travis.sh
branches:
only:
- gh-pages
deploy:
provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure
keep-history: true
on:
branch: gh-pages
And then to git push on the gh-pages branch instead of the master hoping it will deploy then on the master one such as when I did git push to the master one and it deployed on the gh-pages, but it does not update the master one in this case and so, the modifications are not considered.
And also, when I tried not to use the gh-pages step, the changes were deployed by Github/pages before the end of the Travis tests, so the Github page was updated even if the tests failed.
Is there a way I did not think about to make this works?
Related
I have been using Github pages with a custom domain putting all assets including index.html in the root folder of the repository.
Setting the project to be deployed using Github pages at first; All went well with the default action; index.html was served and everything was functional.
Now because I'm trying to modularize and clean the project, nothing is left in the root folder except the necessary build configuration files (along with source).
Locally npm run build part of my build process works fine. I can then serve files from docs folder (because Github uses either root or docs folder) my bundle goes to docs; So I also changed that configuration in Github pages:
(The DNS check goes green after seconds.)
So I defined a NodeJS action to replicate my local build process as:
name: Node.js CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout#v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
My actions page shows this order:
I assume that build is done before Github pages does its internal configurations.
I also made sure the CNAME file is still there (/docs) after each build.
Is using (/docs) folder fine to serve the static site ? same as root ?
and is my action being run before Github pages comes into place ?
For reference: my site is inaccessible: https://mylinks.space/
The last thing I can thing of is that because the site is served from a different folder, now CNAME file needs time to be propagated (DNS checking).
#jonrsharpe: That was it.
For reference: a solution here is to make another branch, add the folder (not ignored) and push that only folder to that branch, for example "gh-pages" branch.
That's a perfect solution for this particular case. I had to remove the folder again from "main" branch though. You can automate the process of git commands with a script.
This is the process for my case: (docs in .gitignore)
Manuel build locally each time
Then
git add docs
git subtree push --prefix docs origin gh-pages
git rm -r docs && git commit -m "Initial dist subtree commit"
git push
I am new to this and I would really need some help. I am trying to deploy my GitHub page from my GitHub repository. I have set the gh-pages branch as my default, I put the code in there.
The code is in here: https://github.com/MelisaBogdan/melisabogdan.github.io
I tried to check if the website is visible with this link https://melisabogdan.github.io but all I see is the readme file. BUT I can perfectly see it by mentioning the folders https://melisabogdan.github.io/root/index.html
I know that many people managed to have their website visible without mentioning the full path ( by simply typing https://melisabogdan.github.io).
Is there anything I can do? I would really appreciate some help I tried what some other people suggested....
Since this is a NodeJS based site, there are many things that you need to do. Do the following steps to see your portfolio at https://melisabogdan.github.io/ . Basically you need to setup a GitHub action in your repository which runs the NodeJS code & then puts the static HTML/CSS files in your gh-pages branch.
Change your default branch to master by going to your_repo > settings > Branches (on left tab) > Default branch
Create a folder .github (include that dot) in the master branch
create a folder workflows within this folder
create a file deploy.yml inside workflows folder
Put the following code in deploy.yml
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout#v2.3.1
with:
persist-credentials: false
- name: Install and Build 🔧
run: |
npm install
npm run build
- name: Deploy 🚀
uses: peaceiris/actions-gh-pages#v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
So finally the folder structure should be like:
melisabogdan.github.io/.github/workflows/deploy.yml
Now commit these files to GitHub
Now if you go to the actions tab in your repo, should see an action running. It will take 2-3 mins & then finally, you should be able to see your site at https://melisabogdan.github.io/
I created a new repo on github and added the .travis.yml file and some sphinx documents but travis won't trigger a build. I can push to another older repository and https://travis-ci.org builds fine. I double checked that the .travis.yml file is exactly like other repositories that do build. I checked github Authorizing OAuth Apps and travis is there.
.travis.yml
language: python
install:
- pip install sphinx sphinx_rtd_theme mock
script:
- sphinx-build -Wv docs/source docs/html
deploy:
# publish docs on push
- provider: pages
skip_cleanup: true
keep-history: false
github_token: $GH_TOKEN
local_dir: docs/html
on:
branch: master
I made a second repo just to make sure I did it correctly.
I follow my instructions for setting up a GitHub, sphinx and travis each time I create a repo.
I have a personal website on a GitHub repo called personal-website and every-time I am making changes locally, I have to SSH into my server (DigitalOcean), go to var/www/personal-website and make a git pull.
I am trying to find a way to pull from the master every-time there is a push into the same branch. I read about GitHub actions and wrote a file on .github/workflows/devops.yml
name: Build and Deploy
on:
push:
branches: master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
GitHub Actions result of Build and Deploy job
On my GitHub Actions page, the job is successful. However, there is no automatic pull request that is done on the server side. How can I fix this?
Make a .sh script and do git pull / git commit / git push
I just created a great gallery for my Jekyll blog which builds perfectly on my localhost:4000. However, GitHub pages doesn't support the Jekyll Gallery Generator plug-in I am using: https://github.com/ggreer/jekyll-gallery-generator
I read about the alternative method of hosting Jekyll on a traditional host using FTP (uploading the _site directory) http://jekyllrb.com/docs/deployment-methods/ However, rather than reconfigure my entire site and hosting, It would be great if GitHub Pages could be used somehow even though I'm using a non-supported plugin.
What is a workaround for this?
Depending if you deal with a User/Organization (UO) site or a Project site (P), do :
from your working folder git init
git remote add origin git#github.com:userName/userName.github.io.git (UO) or git remote add origin git#github.com:userName/repositoryName.git (P)
jekyll new . creates your code base
in _config.yml, set the baseurl parameter to baseurl: '' (UO) or baseurl: '/repositoryName' (P)
in .gitignore add _site, it will be versioned in the other branch
jekyll build will create the destination folder and build site.
git checkout -b sources (UO) or git checkout master (P)
git add -A
git commit -m "jekyll base sources" commit your source code
git push origin sources (UO) or git push origin master (P) push your sources in the appropriate branch
cd _site
touch .nojekyll, this file tells gh-pages that there is no need to build
git init init the repository
git remote add origin git#github.com:userName/userName.github.io.git (UO) or git remote add origin git#github.com:userName/repositoryName.git (P)
git checkout master (UO) or git checkout -b gh-pages (P) put this repository on the appropriate branch
git add -A
git commit -m "jekyll first build" commit your site code
git push origin master (UO) or git push origin gh-pages (P)
You now have something like Octopress does. Look at their rake file, there are some nice comments inside.
Better way is to configure Travis to automate deployment of jekyll with non-supported plugins. Follow Travis getting started guide to enable Travis for your repo.
Create script/cibuild with the following content
#!/usr/bin/env bash
set -e # halt script on error
bundle exec jekyll build
touch ./_site/.nojekyll # this file tells gh-pages that there is no need to build
Create .travis.yml with the following content (modify as required)
language: ruby
rvm:
- 2.3.3
before_script:
- chmod +x ./script/cibuild # or do this locally and commit
# Assume bundler is being used, therefore
# the `install` step will run `bundle install` by default.
script: ./script/cibuild
# branch whitelist, only for GitHub Pages
branches:
only:
- master
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer
sudo: false # route your build to the container-based infrastructure for a faster build
deploy:
provider: pages
skip_cleanup: true
keep-history: true
local_dir: _site/ # deploy this directory containing final build
github_token: $GITHUB_API_KEY # Set in travis-ci.org dashboard
on:
branch: master
Deployment steps (after every push):
Build will be created using our custom script script/cibuild in _site directory
_site will be pushed to gh-pages branch.
github pages will serve site as it is without building it again (because of .nojekyll file)
Reference: My repository https://github.com/armujahid/armujahid.me/ is using this method for continuous integration using Travis CI