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
Related
In the package.json file, I have added a dependency that is referencing one of our public repositories. The dependency in the package.json looks like below:
"ffprobe-static": "git+https://github.com/company-name/repo-name.git",
I can successfully run npm install locally and use this dependency, but when I push this code, our GitHub workflows where we execute npm install fails with the below error:
npm ERR! Warning: Permanently added the RSA host key for IP address 'x.x.x.x' to the list of known hosts.
npm ERR! git#github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
I don't understand the reason for this error, since the repository we are referencing is public, and also I can access the same repository when I install dependencies locally.
Note that the repository that is running this code is a private repository, but the referenced repository is public, but under the same organization.
I was able to fix it by adding the below step after checkout in the YAML file. Also, set the persist-credentials option to false in the checkout step.
steps:
- name: Checkout
uses: actions/checkout#v2
with:
persist-credentials: false
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://git#github.com/
You might try a config to force https URLs, at least for testing, in your GitHub workflow:
- name: Fix URL access
run: echo -e '[url "https://github.com/"]\n insteadOf = "ssh://git#github.com/"' >> ~/.gitconfig
- name: Checkout server
uses: actions/checkout#v2
...
Or (as in here, just to illustrate where you can put the git config insteadOf command):
on: push
jobs:
check-elm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Checkout submodules
shell: bash
run: |
# From https://github.com/actions/checkout/issues/116#issuecomment-583221947
git config --global url."https://github.com/".insteadOf
ssh://git#github.com/
git submodule sync --recursive
git -c "http.extraheader=Authorization: basic ${{secrets.GITHUB_ACCESS_TOKEN}}" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/setup-node#v1
with:
node-version: '8.16.0'
- run: npm run test
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.
I'm still playing around with github/circle-ci and conan.
I've got a repository "fcdk", which is a simple C++ library.
I've another repository "fcdk-conan" which contain the conan's recipe to build the first repository (fcdk). This second repository also contains the .circle-ci stuf. All is building well.
These 2 repositories are on github
I would like to know if there is a way to fire a circle-ci build in the second repository when I push some commit on the first repository ?
Only Conan and Github won't be able to solve your problem, but you can use Circle CI to trigger a new build when the first build pass.
https://circleci.com/docs/2.0/api-job-trigger/
version: 2
.build-steps: &build-steps
steps:
- checkout
- run:
name: Build project
command: .circleci/run.sh
- run:
name: Trigger Conan build
command: curl --user ${CIRCLE_API_USER_TOKEN}: \
--data build_parameters[CIRCLE_JOB]=build_conan \
--data revision=$CIRCLE_SHA1 \
https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/$CIRCLE_BRANCH
jobs:
xcode10:
macos:
xcode: "10.2"
<<: *build-steps
gcc-7:
docker:
- image: conanio/gcc9
<<: *build-steps
workflows:
version: 2
build_and_test:
jobs:
- gcc-9
- xcode10
The example above shows a YAML file which contains a generic build for Linux and OSX, where the curl command is executed to trigger the Conan build. Of course, you will need to customize that command with your project parameters.
This idea can be reproduced on Travis CI, Appveyor, Gitlab CI, Azure ...
Regards!
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.
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.