diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 303e2df..e0384c0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,3 @@ -# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: Build on: @@ -18,8 +15,8 @@ jobs: uses: actions/setup-node@v1 with: node-version: '12.x' - - run: npm install -g @angular/cli - - run: bash build.sh + - run: npm install + - run: npm run lint && npm run build:prod - name: Upload a Build Artifact uses: actions/upload-artifact@v2.1.4 @@ -27,8 +24,12 @@ jobs: name: dist path: ./dist/index/* + - name: Package products + - run: cd dist/index/ && tar -cf index.tar ./* && cp index.tar ../../ + - name: SCP uses: appleboy/scp-action@master + with: host: ${{ secrets.SSH_HOST }} username: ${{ secrets.SSH_USERNAME }} diff --git a/.github/workflows/buildTest.yml b/.github/workflows/test.yml similarity index 52% rename from .github/workflows/buildTest.yml rename to .github/workflows/test.yml index 6986121..80e0cf4 100644 --- a/.github/workflows/buildTest.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: test +name: Test on: push: @@ -16,5 +16,11 @@ jobs: uses: actions/setup-node@v1 with: node-version: '12.x' - - run: npm install -g @angular/cli - - run: bash build.sh + - run: npm install + - run: npm run lint && npm run build + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v2.1.4 + with: + name: devDist + path: ./dist/index/* diff --git a/build.sh b/build.sh deleted file mode 100644 index eac3ff2..0000000 --- a/build.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -basePath=$(pwd) - -$(hash node 2>/dev/null) -if ! [ $? ]; then - echo -e "\t\t请先安装nodejs -------> https://nodejs.org/" - exit 1 -else - echo -e "\t\t nodejs\t\t $(node --version)" -fi - -$(hash npm 2>/dev/null) -if ! [ $? ]; then - echo -e "\t\t Can't find command npm" - exit 1 -else - echo -e "\t\t npm\t\t $(npm --version)" -fi - -$(hash ng 2>/dev/null) -if ! [ $? ]; then - echo -e "\t\tinstall angular cli to build the project" - npm install -g @angular/cli -else - echo -e "\t\t angular-cli\t\t $(ng --version)" -fi - -# index -echo -e "\t\tBuild for index page " -npm install && ng build --prod - -cd ./dist/index/ && tar -cf index.tar ./* && cp index.tar $basePath - -#cd "$basePath" - -## admin -#echo -e "\t\tBuild for admin page " -#cd $basePath/admin && npm install && ng build --prod -#cd ./dist/admin/ && sed '6s/\"\/\"/\"\/admin\/\"/g' index.html > index.txt && cp index.txt index.html -# cd .. && tar -cf admin.tar ./admin/ && cp admin.tar $basePath diff --git a/package.json b/package.json index a10bca8..1ac71d2 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "ng": "ng", "start": "ng serve", "build": "ng build", + "build:prod": "ng build --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e"