Skip to content

debug: test triggering coolify deployment via additional debug steps #89

debug: test triggering coolify deployment via additional debug steps

debug: test triggering coolify deployment via additional debug steps #89

Workflow file for this run

name: Deploy App
on:
push:
branches: [main,debug/deploy]
workflow_dispatch:
env:
NODE_VERSION: '22'
JAVA_VERSION: '21'
jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Build Frontend
working-directory: frontend
run: |
npm ci
npm run build
- uses: actions/upload-artifact@v4
with:
name: frontend-build
path: frontend/dist/
build-backend:
runs-on: ubuntu-latest
needs: build-frontend
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: frontend-build
path: backend/src/main/resources/static
- uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn -B -DskipTests clean package --file backend/pom.xml
- name: Verify JAR
run: |
if [ ! -f backend/target/app.jar ]; then
echo "Error: app.jar not found!"
exit 1
fi
ls -lh backend/target/app.jar
- uses: actions/upload-artifact@v4
with:
name: app.jar
path: backend/target/app.jar
retention-days: 1
push-to-docker-hub:
runs-on: ubuntu-latest
needs: build-backend
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: app.jar
path: backend/target
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ secrets.DOCKERHUB_IMAGE }}:latest
${{ secrets.DOCKERHUB_IMAGE }}:${{ github.sha }}
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_IMAGE }}:buildcache
cache-to: type=registry,ref=${{ secrets.DOCKERHUB_IMAGE }}:buildcache,mode=max
deploy:
needs: push-to-docker-hub
runs-on: ubuntu-latest
steps:
- name: Check if secrets are loaded
run: |
if [ -z "${{ secrets.COOLIFY_API_TOKEN }}" ]; then
echo "::error:: COOLIFY_API_TOKEN is not set or empty!"
exit 1
else
echo "COOLIFY_API_TOKEN is loaded."
fi
if [ -z "${{ secrets.COOLIFY_API_URL }}" ]; then
echo "::error:: COOLIFY_API_URL is not set or empty!"
exit 1
else
echo "COOLIFY_API_URL is loaded."
fi
- name: Get GitHub Runner IP
id: ip
run: echo "RUNNER_IP=$(curl -s https://api.ipify.org)" >> $GITHUB_OUTPUT
- name: Show Runner IP
run:
echo "The runner's public IP is ${{ steps.ip.outputs.RUNNER_IP }}"
- name: Test Coolify API (Debug Only)
if: github.ref != 'refs/heads/main'
run: |
echo "🔍 DEBUG MODE - Testing API without actual deployment"
response=$(curl -v -X POST \
-H "Authorization: Bearer ${{ secrets.COOLIFY_API_TOKEN }}" \
"${{ secrets.COOLIFY_API_URL }}" 2>&1)
echo "Full curl output:"
echo "$response"
- name: Trigger Coolify Deployment (Production Only)
if: github.ref == 'refs/heads/main'
run: |
response=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer ${{ secrets.COOLIFY_API_TOKEN }}" \
"${{ secrets.COOLIFY_API_URL }}")
http_code=$(echo "$response" | tail -n1)
if [ "$http_code" -ne 200 ] && [ "$http_code" -ne 201 ]; then
echo "Deployment failed with HTTP $http_code"
exit 1
fi
echo "Deployment triggered successfully"