Git Product home page Git Product logo

deployment_vue's Introduction

阿里云服务器一键部署vue项目

1.生成vue项目demo

vue create my-project

2.上传vue项目到github

git remote add origin https://github.com/ynzy/deployment.git
git push -u origin master

3.本地生成公钥和私钥

 ssh-keygen -t rsa -C autodeployment -f deployment
-------------
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in deployment.  // 私钥
Your public key has been saved in deployment.pub. // 公钥
The key fingerprint is:
SHA256:egPfdeoMwy8eaCMnA07kZp1cgL7i/2PZmGWAI3eD0y8 autodeployment
The key's randomart image is:
+---[RSA 2048]----+
|     ..          |
|    .  .         |
|   ..+  .        |
|  .oBo=o         |
|   o*==+S   . .  |
|  .=..E+++ . o   |
| . .. =OO * .    |
|  .   *B.o.B     |
|   ..o.. ...+    |
+----[SHA256]-----+
  1. 查看所有文件
ls -la
-----------------
drwxr-xr-x 1 Administrator 197121        0 5   1  2019  .ssh/
-rw-r--r-- 1 Administrator 197121     1679 2  27 14:51  deployment
-rw-r--r-- 1 Administrator 197121      397 2  27 14:51  deployment.pub
  1. 进入.ssh目录将deployment拷贝进去
// 拷贝 要拷贝的文件目录 拷贝到的文件目录,.代表当前目录
cp ~/deployment .

4.返回根目录,把公钥拷贝到远端服务器

// 拷贝到远端  拷贝的文件  服务器用户名@服务器地址:当前目录
scp deployment.pub root@47.95.119.112:.
  1. 把公钥写入远端服务器.ssh目录下
  • 进入.ssh目录查看有没有authorized_keys文件,没有则创建一个
ls -la 
------------
total 8
drwx------  2 root root 4096 Dec 25 03:27 .
dr-xr-x---. 5 root root 4096 Feb 27 15:05 ..
-rw-------  1 root root    0 Feb 16 08:05 authorized_keys
  • 返回上一级执行写入命令
cat deployment.pub >> ~/.ssh/authorized_keys

5.拷贝本地私钥到github

  • 找到私钥文件,复制到github
  • github项目地址->settings->Secrets
  • 添加私钥
name:ALYUN
value:私钥

开启workflow自动工作流

  • 项目中找到actions -> node.js
  • 点击之后会生成一个文件
name: Node.js CI # 自动部署名字

on: [push]  # 发生push时,执行git push命令会触发这里

jobs:
  build:

    runs-on: ubuntu-latest  //运行的系统

    strategy:
      matrix:
        node-version: [8.x, 10.x, 12.x]  # nodejs版本,写几个版本号测试几次,我们用12.x就可以了

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - run: npm install
    - run: npm run build --if-present
    - run: npm test
      env:
        CI: true
# 需要写的一些配置
    - name: Deploy  //当前插件名字
      uses: easingthemes/[email protected]  //使用这个人开发的一个插件
      env: 
        SSH_PRIVATE_KEY: ${{ secrets.ALYUN }}  # 秘钥名字
        ARGS: "-rltgoDzvO --delete" # 固定配置
        SOURCE: "dist/"  # 项目打包之后的目录
        REMOTE_HOST: "47.95.119.112" # 服务器地址
        REMOTE_USER: "root" # 服务器用户
        TARGET: "/www/autodeploy" # 指定服务器目录

deployment_vue's People

Contributors

ynzy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.