From 33a9c8e9abb12f625407c2cede973a6b9dd62e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BA=91=E9=A3=9E?= Date: Fri, 25 Mar 2022 13:48:41 +0800 Subject: [PATCH] feat:add github action --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++++++++ .github/workflows/cypress.yml | 30 +++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/cypress.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f9723d3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,41 @@ +name: build + +on: + push: + branches: [main] + paths: + - 'src/**' + - 'index.html' + - 'package.json' + - 'vite.config.ts' + +jobs: + build: + runs-on: ubuntu-latest + + 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 i yarn -g + - run: yarn + - run: yarn run build + - run: mv dist canvas-editor + - name: Copy folder content recursively to remote + uses: garygrossgarten/github-action-scp@release + with: + local: canvas-editor + remote: ${{ secrets.PATH }} + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + rmRemote: true + - name: Executing remote ssh commands + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + script: sed -i 's/<\/body>/${{ secrets.SCRIPT }}<\/body>/g' ${{ secrets.PATH }}/index.html diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml new file mode 100644 index 0000000..8fa066a --- /dev/null +++ b/.github/workflows/cypress.yml @@ -0,0 +1,30 @@ +name: cypress + +on: + push: + branches: [main] + paths: + - '.github/workflows/*' + - 'cypress/**' + - 'src/**' + - 'index.html' + - 'package.json' + - 'vite.config.ts' + +jobs: + cypress: + runs-on: ubuntu-latest + container: cypress/browsers:node16.14.0-slim-chrome99-ff97 + + 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 i yarn serve -g + - run: yarn + - run: yarn run build + - run: mv dist canvas-editor + - run: serve . -l 3000 & + - run: yarn run cypress:run \ No newline at end of file