name: Build and Deploy on: push: branches: - main tags: - 'v*' pull_request: branches: - main env: REGISTRY: git.viaeon.com IMAGE_NAME: admin/taskpool-react jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup pnpm uses: pnpm/action-setup@v4 with: version: 9 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '22' - name: Install dependencies working-directory: web run: pnpm install --frozen-lockfile - name: Build working-directory: web run: pnpm build - name: Upload artifact uses: actions/upload-artifact@v3 with: name: dist path: web/dist docker: needs: build runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - name: Checkout uses: actions/checkout@v4 - name: Download artifact uses: actions/download-artifact@v3 with: name: dist path: web/dist - name: Login to Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.REGISTRY_USER }} password: ${{ secrets.REGISTRY_PASSWORD }} - name: Build and push uses: docker/build-push-action@v5 with: context: . push: true tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} deploy: needs: docker runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - name: Deploy to server uses: applebox/ssh-action@v1.0.3 with: host: ${{ secrets.SSH_HOST }} username: ${{ secrets.SSH_USER }} password: ${{ secrets.SSH_PASSWORD }} script: | cd /opt/taskpool docker compose pull docker compose up -d docker image prune -f