on: push: branches: - main jobs: build: runs-on: docker # ? check what it really means steps: - name: Checkout git repository uses: actions/checkout@v4 - name: "Install pnpm" uses: pnpm/action-setup@v4 with: version: 10 - name: Setup Nodejs uses: actions/setup-node@v4 with: node-version: 22 - name: "Install dependencies" run: pnpm install - name: "Lint code" run: pnpm run lint - name: "Checking code format" run: pnpm run format:check - name: "Build the project" run: pnpm run build - name: Save the result for deployment uses: actions/upload-artifact@v3 with: name: build-artifact path: "dist/" deploy: needs: build runs-on: docker steps: - name: Install Deployment Tools run: | if command -v apk >/dev/null; then apk add --no-cache rsync openssh-client else apt-get update && apt-get install -y rsync openssh-client fi - name: Setup SSH uses: https://github.com/webfactory/ssh-agent@v0.9.0 with: ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - name: Download Artifact uses: actions/download-artifact@v3 with: name: build-artifact path: ./dist - name: Push run: | rsync -avz -e "ssh -p ${{ secrets.SERVER_PORT }} -o StrictHostKeyChecking=no" \ --delete ./dist/ \ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }}:${{ vars.DESTINATION }} notify: needs: deploy runs-on: docker if: always() # Always run steps: - name: Send Discord Notification run: | STATUS="${{ needs.deploy.result }}" COLOR=$([ "$STATUS" == "success" ] && echo "4582179" || echo "16711680") curl -H "Content-Type: application/json" \ -X POST \ -d '{ "embeds": [{ "title": "Deployment Report", "color": '$COLOR', "description": "Status: **'$STATUS'**\nRepo: ${{ github.repository }}\nCommit: ${{ github.sha }}" }] }' \ "${{ secrets.DISCORD_WEBHOOK_URL }}"