Overview of Automated Deployment

What is deployment

First of all, let’s talk about what deployment is. Everything from the initial project being created using scaffolding, to the local development server being set up for the project, to the code being built to produce usable code for the target environment. Deployment is the process of getting the software up and running in an environment after development, generating a working package from the source code, putting the package in the environment to be deployed, and configuring it to work in the target environment as well.

What is automated deployment

In a simple sentence: all operations during deployment are automated without manual intervention.

Benefits of automated deployment

Compared with traditional manual deployment, for example, if you add a new function to your project, you have to go through the process of local update-build-release, which seems to be nothing difficult, but once there are many projects and frequent deployment, this is inefficient and there will be artificial misoperation, so automated deployment he came ~

Automated deployment tools

Jenkins, Gitlab CI, GitHub Actions, etc. In this article, we will use GitHub Actions as an example to demonstrate the process of automatic deployment.

Automated deployment process

1. Environment preparation

  • Linux server
  • Code is hosted to the GitHub remote repository

Note here the official server requirements, currently supported

This article uses Ubuntu 20.04 for Linux as an example

2. Making the Settings

Go to GitHub —-> User Settings –> Developer Settings –> Personal Access Tokens –> Generate new tokens —> Generate token

It’s important to note that the generated value is only displayed once, so save it, and if you didn’t save it, regenerate it

3. Project Settings

Go to the project repository –> Settings –> secrets –> New Secrets

Note here, in step 2 generate the token, we said whatever the name is, just take that value and fill it in here, in step 3 we recommend to call it token, because it will be used in the subsequent configuration, if it is not token, you will have to modify the configuration file later

4. Within the local development project

In the project root directory to create. Making/workflows/main yml file, the file is a specific workflow, here basically is the folder name and file name. The main, yml can refer to the main yml, pm2. Json can reference pm2. Json,


5. git tag

Git tag v0.0.1 and git push Origin v0.1.1 will trigger the deployment. Because we set it up in the main.yml file to trigger deployment when positioning push with a v

6. Verify the effect

Go back to GitHub and click Actions

Go to the specific build to view build-and-deploy

Finally, all tasks are successful, so it means that the automatic deployment of the project has been successful, and the code needs to be deployed online after subsequent updates, so there is no need to repeat those tedious work, just repeat the fifth step, you can trigger the automatic deployment