Skip to content

Instantly share code, notes, and snippets.

@vinniefalco
Created February 15, 2020 01:36
Show Gist options
  • Save vinniefalco/7b5487cdca94bdcce701107ce94f4251 to your computer and use it in GitHub Desktop.
Save vinniefalco/7b5487cdca94bdcce701107ce94f4251 to your computer and use it in GitHub Desktop.
1. For the sake of this tutorial we need a user repo (githubUsername.github.io).
On your root of jekyll project,
Create a folder named “.circleci”, inside this folder we’ll put a file named “config.yml”
(attached on upwork message).
Here is all the circleci thing was located.
Create a develop branch : git checkout -b develop
And push it : git push -u origin develop.
Now go to repo setting in github.
2. And change main branch to develop, and hit update button!
3. Goto https://circleci.com/signup/, authenticate for the current repo.
https://circleci.com/docs/2.0/project-build/#section=getting-started
4. Go to this repo setting
And set “only build pull request” to “on”
And manage github check (allow circleci check).
5. Now it’s time to open config.yml,
And change the following line according to your github account.
git config --global user.name "<your_name>"
git config --global user.email "<your_email>"
Then we need to add deploy key to the config.
https://circleci.com/docs/2.0/gh-bb-integration/#creating-a-github-deploy-key
Replace fingerprint below with yours (see the creating-a-github-deploy-key )
- add_ssh_keys:
fingerprints:
- "<your own fingerprints>"
6. Here’s the jekyll parts
Initially I created the preview based on PR number, for example for PR6
The preview site url would be: preview/6
But this introduce some problem in jekyll,
We can specify baseurl, so that asset path would be correct, this will be set via
Additional jekyll config.
Regular jekyll config : _config.yml lives in the project root, here , we set baseurl: ""
We need to create new config, and name it like : _config_develop.yml
here , we set baseurl: "/preview"
See , this line in circleci config :
- run: bundle exec jekyll build --config _config_develop.yml
7. In summary,
Given a regular jekyll project, for this to work we need :
a. .circleci folder and config.yml
b. Duplicate jekyll _config.yml, rename the duplicate to _config_develop.yml
c. Open _config_develop.yml and set baseurl: "/preview"
8. Git flow,
We have set develop as our main branch,
And master branch for static files.
Now we need to create a new branch, name it test or something else
git checkout -b test
Make some changes to a file,
git add . , and git commit -m “commit message”
git push -u origin test, to push the changes to the remote repo.
Go to github and then make a PR from test to develop branch.
9. Go to circelci dashboard to check the circleci workflow
At the end, it will commit static files to master branch.
And create /preview folder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment