Can't build github page generic error - github

I am using travis CI to publish my jekyll site.
Whole repo.
The relevant parts are:
.travis.yml
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:
- gh-pages # test the gh-pages branch
- /pages-(.*)/ # test every branch which starts with "pages-"
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
github-token: $GITHUB_TOKEN # Set in the settings page of your repository, as a secure variable
keep-history: true
on:
branch: gh-pages
My cibuild file is the following:
#!/usr/bin/env bash
set -e # halt script on error
bundle exec jekyll build
This is the full log of the build.
Everything seems to be deploying ok, no errors.
But on Github I get:
The troubleshooting is no help.
Just in case. I'm running jekyll-assets and I can't to build it with gh-pages directly, hence travis, see https://github.com/github/pages-gem/issues/189 specifically: https://github.com/github/pages-gem/issues/189#issuecomment-319070628
I am really not sure how to process, the github error is of no help.

If your site is already built by CI, you can add a .nojekyll file at the root of your code to instruct gh-pages not to generate but just publish you site.

Related

Is there a way to use secrets in flutter web deployments on Netlify with or without using GitHub workflows?

I have a Flutter web app and I'm not much familiar with GitHub workflows. I have a dotenv file that stores a token needed by another file in the project.
For the deployments, I'm using this build command in Netlify:
if cd flutter; then git pull && cd ..; else git clone https://github.com/flutter/flutter.git; fi && flutter/bin/flutter config --enable-web && flutter/bin/flutter build web --release
One more reason why I chose to use this instead of a GitHub workflow is because this doesn't add the build directory in my repo itself.
Now a need has arised to use this dotenv in my project. But to build and deploy this using the aforementioned command, the dotenv should always be version controlled. Otherwise Netlify won't be able to detect it.
I have come across this stackoverflow post but this doesn't seem to solve my problem.
Is there any way I can directly pass the environment secrets to Netlify needed for build and deploy for Flutter? Or is there any workflow to directly deploy (on push) to Netlify, without storing the build files in my repo?
This is my current netlify build settings:
You can simply put your build files onto another branch using GitHub workflows.
First create a empty branch named build and initiate the branch using an empty commit. Follow these steps:
git checkout --orphan build
git rm -rf . This removes existing files
git commit --allow-empty -m "some message"
Now come back to the master branch. And run these steps:
base64 path/to/dontenv and copy the output of this command. This actually decodes the contents of your DOTENV into a string.
Paste this output in a new GitHub repo project secret and name it DOTENV.
Now simply add this DOTENV in .gitignore.
Create a new GitHub workflow.
Run mkdir -p .github/workflows.
nano .github/workflows/build.yml and paste this:
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout#v2
#I am assuming your dontenv was in lib/
#This now decodes your dotenv back and writes the contents into lib/dotenv
- run: echo "${DOTENV// /}" | base64 -d > lib/dotenv
env:
MAIN: ${{ secrets.DOTENV }}
- name: Set up Flutter
uses: subosito/flutter-action#v1
with:
channel: 'stable'
- name: Get dependencies
run: flutter pub get
- name: Run analyze
run: flutter analyze .
- name: Build release
run: flutter build web --release
- name: Upload artifacts
uses: actions/upload-artifact#v1
with:
name: build
path: build
deploy-build:
needs: build
runs-on: ubuntu-latest
steps:
- name: Clone the repoitory
uses: actions/checkout#v2
with:
ref: build
- name: Configure git
run: |
git config --global user.email ${GITHUB_ACTOR}#gmail.com
git config --global user.name ${GITHUB_ACTOR}
- name: Download website build
uses: actions/download-artifact#v1
with:
name: build
path: build
- name: Commit and Push
run: |
if [ $(git status --porcelain=v1 2>/dev/null | wc -l) != "0" ] ; then
git add -f build
git commit -m "gh-actions deployed a new build"
git push --force https://github.com/${GITHUB_REPOSITORY}.git HEAD:build
fi
This will create the build files in the build branch. And your master branch will remain unaffected. After every push, this GitHub action will get triggered and build and commit your build files in the build branch. To deploy, simply deploy this build branch.

Why is GitLab CI/CD ignoring certain files when passing them as an artifact?

I have a simple CI/CD setup for my GitLab repo.
During the build job, the commands install NPM, run a build script which uses Webpack to build the JS/SCSS etc.
Then, since I don't want any of the source files to be uploaded to my server, I remove them along with some other files that are not needed for deployment.
However, when the parent directory htdocs is uploaded as an artifact so it can be used in the deploy job, when I run ls -la and ls ./assets -la in the deploy job, I can still see all of the files that I removed earlier in the build job.
When I download the artifact ZIP file from the browser, everything is correct as all of my unneeded files are gone.
Why is it then I can still see BOTH the source and distributed files in the build job? Is this a bug?
At the moment this is causing all of my source files to be uploaded to my server which is not what I want. Can anyone help?
image: node:11.9.0
before_script:
- cd ./htdocs
stages:
- build
- deploy
build:
stage: build
script:
- npm install --quiet
- npm run build
- rm -rf node_modules assets/src
- rm -r .??* package.json package-lock.json README.md webpack.*.js
artifacts:
paths:
- ./htdocs/
deploy:
stage: deploy
cache: {}
dependencies:
- build
script:
- ls -la
- ls ./assets/ -la
Every job in GitLab by default clones the repository and then downloads any artifacts you set in the dependencies. You should see this at the start of the job log of the deploy stage.
To stop your source files from being uploaded in your deploy stage, you could set the GIT_STRATEGY to none.
Eg:
deploy:
stage: deploy
cache: {}
variables:
GIT_STRATEGY: none
dependencies:
- build
script:
- ls -la
- ls ./assets/ -la

Travis CI - How to push into master branch?

I have a Travis CI project connected to GitHub that tries to update content in the Github repo and push them back to GitHub, both master and gh-pages branches.
However, although my travis-ci log files says everything is ok, I only see the gh-pages branch updated, but not the master branch.
My travis.yml file is:
language: node_js
node_js: stable
language: python
python: 3.6
# Travis-CI Caching
cache:
directories:
- node_modules
- pip
# S: Build Lifecycle
install:
- npm install
- npm install -g gulp
- python -m pip install requests
- python -m pip install bs4
- python -m pip install lxml
before_script:
- cd archive_builder
- python build_archive.py
- cd ..
script:
- gulp dist
after_script:
- cd dist
- git init
- git config user.name "my git name"
- git config user.email "my git email"
- git add -A
- git commit -m "travis -- update gh-page"
- git push --force --quiet "https://${GH_TOKEN}#${GH_REF}" master:gh-pages
- sh ../purgeCF.sh $CF_ZONE $CF_KEY $CF_EMAIL
- cd ..
- git add -A
- git commit -m "travis -- update master files"
- git push --quiet "https://${GH_TOKEN}#${GH_REF}" HEAD:master
# E: Build LifeCycle
branches:
only:
- master
env:
global:
- GH_REF: github.com/mygitname/myprojectname.git
In this script, I first update and build website sourcefiles with gulp, storing them into "dist" folder. Then I push content in "dist" to my gh-pages branch, and push everything else to my master branch.
The credentials are stored as security keys with Travis and should work correctly.
To push "dist/", I created a new ".git/" under "dist/" and force push it as new.
To push everything else, I could not do it because the root repository already contains ".git" folder and I do not want to lose my previous commits. It should work.
Thanks for help.
I found most articles or answers were talking about how to deploy to gh-pages branch, and most ways is not work for me , i debug this issue on travis for several days, i will list key steps about how to push to master brach on travis
e.g. Below is my doc repository script, travis will update readme.md automated.
Generate github token, you can refer to the article https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
Set Environment Variables
GH_REF githu.com/clownvary/docs.git your repository address
GITHUB_API_KEY *********** your token generated on step 1
Script
os: osx
language: node_js
cache:
directories:
- node_modules
node_js:
- 'lts/*'
before_install:
- git pull
- brew install tree
install:
- npm install
script:
- npm run updateReadme
after_success:
- git config user.email "travis#travis.org"
- git config user.name "travis" # this email and name can be set anything you like
- git add README.md
- git commit --allow-empty -m "updated README.md"
- git push https://clownvary:${GITHUB_API_KEY}#${GH_REF} HEAD:master #clownvary is my username on github, you need to use yourself , do not use travis or others.
Hope this can help you
Even though #gary wang method is working, there is much simpler method that can push into GitHub master branch directly.
Just add target_branch variable under deploy section, and assign it with master.
Documentation on Travis CI GitHub Pages Deployment: https://docs.travis-ci.com/user/deployment/pages/
Sample contents of .travis.yml:
language: node_js
...
...
...
deploy:
provider: pages
skip_cleanup: true
keep_history: true
github_token: $github_token # Your GitHub token set in Travis CI console
target_branch: master # Add this line - To push into GitHub master branch
on:
branch: staging # Your GitHub repo default branch
This method is tested and working as per expected.

How to deploy to github releases from travis

I have some repository with a electron-js project. I'm trying to setup build and deploy to github releases from travis CI.
I have next config:
language: node_js
node_js:
- "8"
before_install:
- cd app
install:
- npm install
os:
- linux
- osx
env:
- TARGET_ARCH=x64
script:
- npm run dist
branches:
only:
- master
deploy:
provider: releases
skip_cleanup: true
api_key: $GH_TOKEN
Travis successfully builds app, but didn't upload artifacts to github releases.
As I understood the documentation, It should create a new release with tag untagged-* and upload files to it.
Now I have this messages in build log:
skipped publishing file=Cromberg_1.2.1_amd64.deb reason=existing type
not compatible with publishing type tag=v1.2.1 version=1.2.1
existingType=release publishingType=draft
1.2.1 is a previous tag. What am I doing wrong?
I want to automatically build and creating releases with artifacts on every commit with tags in master branch. But now I just trying to setup deploy on any event.
You need to set the deploy parameters correctly in travis.yml, look this:
language: go
go:
- "1.10"
script:
- CGO_ENABLED=0 go build
- ls
deploy:
provider: releases
api_key: $TOKEN
file: "test"
skip_cleanup: true
on:
tags: false
If you set tags: false, then travis will release your app with untagged tag like this:
To deploy to github releases on tags you should have a part of config like this:
deploy:
provider: releases
skip_cleanup: true
api_key: $GH_TOKEN
file_glob: true
file:
- "dist/Cromberg-*-x86_64.AppImage"
- "dist/Cromberg_*_amd64.deb"
- "dist/Cromberg-*.dmg"
on:
tags: true
Also don't set branches in config like this:
branches:
only:
- master
Because it will build only on this branch and don't use tags (but in deploy config we set tags: true)
Thus, when you make a commit with some tag on master, it will build your app twice: first build on master branch, deploy step will be skipped. Another build on tag, it will create release during this build and upload files to release.

How to use a private repository in CircleCI?

I am a tester of plugins of Redmine. I want to test all plugins.
In order to do so,I set .circleci/config.yml under one plugin's repository (managed by Github) and tried to test. But I got following mistake message.
#!/bin/bash -eo pipefail
git clone https://github.com/xxxxxx/lad.git
Cloning into 'lad'...
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Exited with code 128
I want to find out the way of getting the clones of private repositories which are different from the repository I am using now.
The following is my .circleci/config.yml now.
version: 2
jobs:
build:
docker:
- image: ruby:2.3.0
environment:
- LANG: C.UTF-8
environment:
BUNDLE_GEMFILE: /root/project/.circleci/Gemfile
steps:
- checkout
- run: git clone --depth=1 --branch=${REDMINE_VERSION:-3.4-stable} https://github.com/redmine/redmine.git
# this is private repository ↓
- run: git clone https://github.com/xxxxxx/lad.git
- run:
name: Check status
command: |
pwd
ls -al
You'd need to add a private SSH key to CircleCI that has access to the GitHub repository that you are trying to clone. This would be done via the CircleCI webapp in the project's settings page. More information here: https://circleci.com/docs/2.0/gh-bb-integration/#enable-your-project-to-check-out-additional-private-repositories