diff --git a/.drone.yml b/.drone.yml index 511871e..28dd2e4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,29 +1,15 @@ kind: pipeline type: docker -name: default +name: cd steps: -- name: test - image: liuchuzhang/node-pnpm - commands: - - pnpm install - - pnpm run test - -- name: docker-build - image: plugins/docker - settings: - repo: liuchuzhang/blue-music-be - tags: latest - username: - from_secret: docker_username - password: - from_secret: docker_password - - name: deploy image: appleboy/drone-ssh environment: SSH_DEPLOY_SHELL: from_secret: ssh_deploy_shell + DOCKER_TAG: + from_secret: docker_tag settings: host: from_secret: ssh_host @@ -35,8 +21,9 @@ steps: from_secret: ssh_password envs: - ssh_deploy_shell + - docker_tag script: - - $SSH_DEPLOY_SHELL -d music -e liuchuzhang/blue-music-be -i music-be -p 4001 -u /api + - $SSH_DEPLOY_SHELL -d music -e $DOCKER_TAG -i music-be -p 4001 -u /api trigger: branch: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0c3ba9f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: CI + +env: + NODE_OPTIONS: --max-old-space-size=6144 + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + test: + name: Run test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2.2.2 + with: + version: '7' + + - name: Set node version + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: "pnpm" + + - name: Install deps + run: pnpm install + + - name: Test + run: pnpm run test + + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Docker Login + uses: docker/login-action@v2.0.0 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v3.1.1 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_TAG }}