Editor’s note: Thanks @Xiaoxiaoxiaodu for contributing this article. Link to Juglans’ Blog. If you also want to experience the automated continuous deployment of flow.ci, submit your application to the flow.ci homepage and the invitation code will be sent to your email 🙂

Flow. Ci is a continuous integration (CI) saas service platform, also known as Travis CI in China, that pulls your code from Github and automates the building, testing, delivery, and deployment of your code through container technology. The whole experience of using Flow. ci is simple, with little intrusion of source code. Although SPA page is used, the speed is quite satisfactory, and even loading is not seen.

In order to thank Flow. ci for sending me the invitation code, I have to say something about flow.ci’s message: Let your code stay and flow. Da! Ya! .

In this article, WE replace the Daocloud platform with Flow. ci, which is a purest continuous integration/deployment platform compared to Daocloud code building and is currently billed as free in beta.

Transformation ideas

  • Disable daoCloud continuous integration
  • Configure flow. Ci continuous integration (core or private key added)
  • Add trigger
  • Commit the Hexo main project modification locallygit committest

The preparatory work

Still keep.daocloudContents and inid_rsaThe private key file

This step is separate because, if it is a new project, you need to add this file. In order to add the private key during continuous integration, please generate the private key file by yourself.

Disable daoCloud continuous integration

Since you are integrating with flow.ci, you should turn off continuous integration of Daocloud, ignore it if it is a new project.

Delete the source codeDockerfileanddaocloud.ymlThe configuration file

This step is optional and does not affect the deployment. However, the two configuration files do not take any effect. If it is a new project, ignore it.

The implementation process

1. Create continuous integration projects

This step is very simple, follow the button in the flow.ci console to Create Project-> Select CODING repository -> Select your user -> Select your Project, complete!

In this case, the items in CODING will have two changes:

  • New webhook for flow.ci
  • Added deployment public key under project (read only)

The creation process gives two interfaces a feel:

The following is the configuration process for a continuous integration project.

2. Configure the continuous integration project environment

Go to the Get Started with Flow. ci screen and select Create Your First Flow. The Hexo we use is based on Node.js, so select Node.js default template:

Select Versions to V5.2.0 ->Create. A workflow is generated based on the selected template (shown above).

3. Configure the continuous integration project workflow

This is the core value of Flow.ci, where our automated deployment is implemented.

The + sign between each workflow node is used to transform the workflow generated by the template, and the transformation is as follows:

A Custom Script node was added and the Test node was removed.

Initialize

Keep the defaults, initial environment variables (provided by flow.ci) and component versions of Node.js.

Git Clone

Keep the default and remove the CODING code.

Cache

Keep the default and cache./node_modules to increase the speed of the next integration.

Install

Keep the default, NPM install installs dependencies by default.

Custom Scrip

We added nodes (plug-ins) by ourselves, the process is mainly completed:

  • Hexo command line installation
  • Copy the private key from the code base and install the private key, no private key will causeHexo dFailure of operation
  • Hexo static site generation and deployment

Change the script to:

Flow_cmd "cp. Daocloud/id_rsa. "--echo flow_cmd "Chmod 600./id_rsa" --echo flow_cmd "eval $(ssh-agent)" --echo flow_cmd "ssh-add./id_rsa" --echo # perform Hexo build and publish flow_cmd "hexo clean" --echo flow_cmd "hexo g" --echo flow_cmd "hexo d" --echoCopy the code

4. Configure the triggers

When the trigger is configured as a master branch, the configuration information is shown in the workflow diagram.

5. Manually test the continuous integration process

Under the Jobs TAB of the project, click the Start Build button -> Select Build on the Master branch and you will see the execution process and log information of the entire workflow (green indicates success, blue indicates execution).

summary

This article describes the transformation from Daocloud continuous integration/deployment to Flow. Ci integration/deployment, which will be used in the same way as before, with automatic deployment triggered by a push to the CODING source library.

Compared to Daocloud code build, flow.ci has the following advantages for continuous integration/deployment:

  • Simpler, intuitive way, easier to understand
  • Apart from saving the private key file in the code base, the entire integration/deployment process does not involve any scripting intrusion into the source code (compared to Daocloud)
  • Richer trigger methods

However, in this way, there is still the security problem that the original private key is saved in the code base, which is also the reason why my CODING code base remains private.

Done!

The above is the “Flow. Ci best Practices” series @ xiaoxiaodu usage share, hope you useful.

flow.ci