Skip to content

Merge pull request #46 from ad-altun/chore/update-readme #96

Merge pull request #46 from ad-altun/chore/update-readme

Merge pull request #46 from ad-altun/chore/update-readme #96

Workflow file for this run

name: Deploy App
on:
push:
branches: [main]
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
# Deployment workflow for PerTiTrack
#
# IMPORTANT: Cloudflare Proxy Configuration
# If deployment fails with HTTP 403 errors from GitHub Actions while working from local (Postman/curl):
# - Check Cloudflare DNS settings for coolify.denizaltun.de
# - Ensure the record is set to "DNS only" (gray cloud), NOT "Proxied" (orange cloud)
# - Cloudflare's proxy can block automated requests from GitHub Actions IPs while allowing browser traffic
#
# Debug steps if needed:
# 1. Verify secrets are loaded: Check COOLIFY_API_TOKEN and COOLIFY_API_URL exist
# 2. Get GitHub Runner IP: curl -s https://api.ipify.org
# 3. Test API with verbose output: curl -v -X POST -H "Authorization: Bearer $TOKEN" $URL
deploy:
needs: push-to-docker-hub
runs-on: ubuntu-latest
steps:
- name: Trigger Coolify Deployment
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"
- name: Summary
run: |
echo "## Deployment Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Branch**: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Triggered by**: @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY