name: Build & Deploy Fiddy (Dokploy) on: push: branches: [ "main" ] env: REGISTRY: git.nicosaya.com/nalalangan/fiddy jobs: build: runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3 - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: 20 - name: Install dependencies run: npm ci - name: Run tests run: npm test --if-present - name: Docker login run: | echo "${{ secrets.REGISTRY_PASS }}" | docker login $REGISTRY -u "${{ secrets.REGISTRY_USER }}" --password-stdin - name: Build Web Image run: | docker build -t $REGISTRY/web:${{ github.sha }} -t $REGISTRY/web:main -f docker/Dockerfile . - name: Push Web Image run: | docker push $REGISTRY/web:${{ github.sha }} docker push $REGISTRY/web:main deploy: needs: build runs-on: ubuntu-latest steps: - name: Checkout repo uses: actions/checkout@v3 - name: Trigger Dokploy Deploy env: DOKPLOY_DEPLOY_HOOK: ${{ secrets.DOKPLOY_DEPLOY_HOOK }} IMAGE_TAG: ${{ github.sha }} run: | if [ -z "$DOKPLOY_DEPLOY_HOOK" ]; then echo "Missing DOKPLOY_DEPLOY_HOOK secret" exit 1 fi curl -fsS -X POST "$DOKPLOY_DEPLOY_HOOK" \ -H "Content-Type: application/json" \ -d "{\"imageTag\":\"$IMAGE_TAG\"}" - name: Wait for Ready Health Check env: HEALTH_URL: ${{ secrets.DOKPLOY_HEALTHCHECK_URL }} MAX_ATTEMPTS: "30" SLEEP_SECONDS: "10" run: | if [ -z "$HEALTH_URL" ]; then echo "Missing DOKPLOY_HEALTHCHECK_URL secret" exit 1 fi bash scripts/wait-for-health.sh