From 0792567f3ead953e8df537698d618ae80213fd75 Mon Sep 17 00:00:00 2001 From: bzp2010 Date: Wed, 21 Oct 2020 22:39:16 +0800 Subject: [PATCH] feat(CI): create NewCI for embedding static files into Go binaries --- .github/workflows/api_newci.yml | 71 +++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/api_newci.yml diff --git a/.github/workflows/api_newci.yml b/.github/workflows/api_newci.yml new file mode 100644 index 0000000000..ce59db7cd4 --- /dev/null +++ b/.github/workflows/api_newci.yml @@ -0,0 +1,71 @@ +name: NewCI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + frontend: + name: Front-End compile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup Node.JS environment for Front-End + uses: actions/setup-node@v1 + with: + node-version: 14.x + + - name: Install Front-End dependencies + run: yarn install + + - name: Build Front-End + run: yarn build + + - name: Store Compiled Front-End files + uses: actions/upload-artifact@v2 + with: + name: dist + path: ./dist/ + + backend: + name: Back-End compile + needs: frontend + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Copy file to Back-End compile environment + uses: actions/download-artifact@v2 + with: + name: dist + path: ./api/dashboard/ + + - name: Setup Golang environment for Back-End + uses: actions/setup-go@v2 + with: + go-version: 1.14 + + - name: Setup Build Environment + run: | + cd ./api/ + sudo go get github.com/rakyll/statik + + - name: Generate Built-in Code + run: | + cd ./api/ + $(go env GOPATH)/bin/statik -src=./dashboard/ + + - name: Build Back-End Binary + run: | + cd ./api/ + sudo go build -o /go/manager-api/manager-api + + - name: Store Compiled Back-End files + uses: actions/upload-artifact@v2 + with: + name: output + path: /go/manager-api/manager-api