Github Actions

Github Actions is Github’s continuous integration service. Click Actions to create a configuration file on your Github project, which is actually a.yml file saved under.github/ Workflows.

1. Basic terminology structure of configuration files

(1) Workflow: Continuous integration of a running process, that is, a workflow.

(2) Job: A Workflow consists of one or more jobs. It is a continuous integrated operation that can complete multiple tasks.

(3) Steps: Each job consists of multiple steps to be completed step by step.

(4) Action: Each step can execute one or more actions in turn.

2, example demo, Github project automatically updated to the cloud server

Github has an official marketplace where you can search for actions that meet your needs. Steps configures uses to reference the action script.

Workflow Push: Branches: [master] Jobs: build: runs-on: Steps: - name: Checkout # To obtain the source code, use actions/checkout@v2 uses: actions/checkout@v2 - name: Use actions/setup-node@v1 uses: actions/setup-node@v1 with: node-version: '12.x' -name: Install and Build static resources run: | yarn config set registry https://registry.npm.taobao.org yarn install yarn build - name: Use easingThemes /[email protected] to SSH to use easingThemes /[email protected] env: SSH_PRIVATE_KEY: ${{secretsecrets.SSH_PRIVATE_KEY}} # Private key, public key copy to server in /root/.ssh/authorized_keys ARGS: ${{secrets.args}} # For any initial/required rsync flag, default -avzr --delete, if there are other files or folders in the directory, you can use --exclude to ignore, such as --exclude /uploads/ SOURCE: REMOTE_HOST: ${{secrets.REMOTE_HOST}} ${{secrets.REMOTE_PORT}} # SSH port number REMOTE_USER: root # SSH user name TARGET: ${{secretsCopy the code

3. Configure sensitive data

Because the deployment to the cloud server requires authentication, the corresponding sensitive data can not be directly exposed, Github can set the corresponding environment variables in the Secrets of the project setting, and then access the corresponding variables through the syntax of ${{}}.

Nginx installation and configuration

Because my server is using Nginx, I’m going to do a quick note here

Nginx is a high-performance HTTP and reverse proxy Web server. It can be used as a reverse proxy server, static resource server, and load balancer in normal application scenarios. Using the Linux OS as an example, you can download the installation package for Windows and Mac.

1, install,

Yum install nginx -y # Centos 7.xCopy the code

2. Relevant folders

Run the RPM -ql nginx command to check where nginx is installed. /etc/nginx/nginx.conf is the main configuration file of nginx.

3. Common operation commands

Nginx -s reload # signal the main process to reload the configuration file, Nginx -s reopen # restart nginx nginx -s stop # stop nginx -s quit # wait for the working process to complete the closed nginx -t # check the final configuration of the current nginx systemctl Enable nginx # Use system administration commands to enable nginx startupCopy the code

4. Common configurations

4.1 Take a look at the master configuration file first/etc/nginx/nginx.confThe basic structure of.

# global configuration, the main effect of global ├ ─ ─ events # Nginx server link configuration | ├ ─ ─ worker_connections 1024; │ ├─ upstream │ ├─ high school for the rest of the server and the rest of the server │ ├─ Server │ ├─ Location │ ├─ Server │ ├─ location # The location to match the corresponding uri │ │ ├ ─ ─ the location │ │ └ ─ ─... │ └ ─ ─... └ ─ ─...Copy the code

4.2 A relatively complete configuration demo

#   For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; Server {listen 80; Server_name www.example.com Rewrite ^(.*)$https://$host$1 # $host$1. Rewrite ^(.*)$https://$host$1 # }	
# Settings for a TLS enabled server.server { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; server_name _; root /usr/share/nginx/html; Ssl_certificate /etc/nginx/nginx/ssl.crt; Ssl_certificate_key /etc/nginx/ nginx/ ssl.key; Ssl_session_timeout 10m; ssl_session_cache shared:SSL:1m; ssl_ciphers HIGH:! aNULL:! MD5; ssl_prefer_server_ciphers on; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; Location / {root /home/dist # index index.html; try_files $uri $uri/ /index.html @rewrites; Location /public {alias /home/public; Autoindex on; Autoindex_exact_size off; # on(default) displays the exact size of the file in bytes; Off Displays the approximate file size. The unit is KB, MB, or GB autoindex_localTime off. # off(default) displays the file time as GMT; On display file for the server time} the location ~ / API / {proxy_pass http://www.example.com:8080; } error_page 404/404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }Copy the code

4.3 Other Configurations

Add Gzip configuration in /etc/nginx/conf.d

gzip on; # default off, Whether to enable gzip gzip_types text/plain text/ CSS application/json application/ X-javascript text/ XML application/ XML application/xml+rss text/javascript; gzip_static on; Gzip_proxied any; Gzip_vary on; # add 'Vary: accept-encoding' gzip_comp_level 6; 1 has the lowest level and 9 has the highest level. The higher the level, the higher the compression rate and the longer the compression time. Gzip_min_length 1k in 8K *16; Gzip_http_version 1.1; The minimum HTTP version required to enable Gzip is 1.1 by defaultCopy the code

reference

  • GitHub Actions tutorial
  • Nginx from entry to practice, 10,000 words in detail!