Browse Source

Add build test ci script

Granty1 4 years ago
parent
commit
9da562c113
2 changed files with 87 additions and 8 deletions
  1. 21 8
      .github/workflows/backend_deploy.yml
  2. 66 0
      .github/workflows/build_test.yml

+ 21 - 8
.github/workflows/go.yml → .github/workflows/backend_deploy.yml

@@ -1,8 +1,21 @@
-name: gin-vue-admin-backend ci&cd
+name: gin-vue-admin backend deploy
 
 on:
   push:
-    branches: [ action-ci ]
+    branches: 
+      - master
+      - action-ci
+    paths:
+      - './server/**'
+    paths-ignore:
+      - './db/**'
+  pull_request:
+    branches: 
+      - master
+    paths:
+      - './server/**'
+    paths-ignore:
+      - './db/**'
 
 jobs:
 
@@ -30,8 +43,7 @@ jobs:
 
     - name: Build
       run: |
-        su root -p $ROOT_PASS
-        go build -o /usr/local/projects/gin-vue/run -v
+        go build -o run -v
       working-directory: ./server
 
     - name: Modify config params
@@ -43,9 +55,10 @@ jobs:
         sed -i 's/%{redis_password}/'$REDIS_PASSWORD'/' config.yaml
       working-directory: ./server
 
-    - name: Move config file 
-      run: | 
-        su root -p $ROOT_PASS
-        mv ./config.yaml /usr/local/projects/gin-vue/config.yaml
+  deploy:
+    - name: Run Dockerfile
+      run: |
+        echo 'There is nothing for the time being' 
       working-directory: ./server
+    
 

+ 66 - 0
.github/workflows/build_test.yml

@@ -0,0 +1,66 @@
+name: gin-vue-admin build test
+
+on:
+    push:
+      branches: 
+        - '*'
+      paths-ignore:
+        - './db/**'
+    pull_request:
+      branches: 
+        - '*'
+      paths-ignore:
+        - './db/**'
+        - '**.md'
+
+jobs:
+  frontend:
+    name: Frontend build 
+    runs-on: ubuntu-latest
+    strategy:
+      matrix:
+        node-version: [12.x]
+      steps:
+        
+      - name: Check out branch
+        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
+        npm run build
+      working-directory: ./web
+        env:
+          CI: true
+      
+    
+  backend:
+    name: Backend build
+    runs-on: ubuntu-latest
+    steps:
+
+    - name: Set up Go 1.13
+      uses: actions/setup-go@v1
+      with:
+        go-version: 1.13
+      id: go
+
+    - name: Check out branch
+      uses: actions/checkout@v2
+
+    - name: Download dependencies
+      run: |
+        go get -v -t -d ./...
+        if [ -f Gopkg.toml ]; then
+            curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
+            dep ensure
+        fi
+      working-directory: ./server
+      
+    - name: Test and Build
+      run: |
+        go build -v -race
+      working-directory: ./server