How to Build a CI/CD Pipeline on CircleCI

Once you got your account on CircleCI and setup your project linked to your git repository, you will have to have a directory named “.circleci” inside the root of your project repo.
Create a file named “config.yml” in there.
Grab the sample script given by CircleCI platform according to your project type.
The first step is to get the building workflow success.
The next step is to get the deployment workflow success.
Key point is writing a beautiful deploy command.
Once it’s working basically, review your deployment checking if any issues exists.
For example, you need to lock the master branch, which is called “repository protection”.
In case you used docker, consider using this command for avoiding dummy images and containers ruin your storage every time you deploy(you may meet "no enough storage" error otherwise).

1docker-compose down
2docker system prune -a -f

If you used SSH to deploy, check your repository on the server.

1cd .git
2vim config
3#find this block:
4[remote "origin"]
5	url =
6	fetch = +refs/heads/*:refs/remotes/origin/*

Put your git credential(oh, god, it's dangerous!) like this:

1  url = https://username:[email protected]/username/blabla.git

Note that more elegant methods exist for this (SSH and non-SSH) regarding security concerns.
Thanks for reading anyhow!
Feel free to ask me in you need further help.
Happy coding!

comments powered by Disqus