name: 'Deploy to rack-server' description: 'Docker imajini build eder, deploy-panel API si uzerinden Traefik arkasinda container olarak yayina alir (DNS + deploy mantigi panelde).' inputs: hostname: description: 'Uygulamanin public hostname i (orn. myapp.akalan.dev)' required: true port: description: 'Container icinde uygulamanin dinledigi port' required: false default: '80' context: description: 'Docker build context (Dockerfile in bulundugu klasor)' required: false default: '.' panel_token: description: 'Deploy panel API token (secrets.PANEL_TOKEN)' required: true panel_url: description: 'Deploy panel adresi' required: false default: 'https://panel.akalan.dev' runs: using: 'composite' steps: - name: Container adini belirle (her zaman repo adi) shell: bash id: name env: REPO_FULL: ${{ github.repository }} run: | NAME="${REPO_FULL##*/}" echo "Kullanilacak container adi: $NAME" echo "value=$NAME" >> "$GITHUB_OUTPUT" - name: Docker imajini build et shell: bash run: docker build -t ${{ steps.name.outputs.value }}:latest ${{ inputs.context }} - name: Panel uzerinden deploy et shell: bash env: PANEL_TOKEN: ${{ inputs.panel_token }} run: | set -e RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "${{ inputs.panel_url }}/api/deploy" \ -H "Authorization: Bearer $PANEL_TOKEN" -H "Content-Type: application/json" \ -d "{\"name\":\"${{ steps.name.outputs.value }}\",\"hostname\":\"${{ inputs.hostname }}\",\"port\":\"${{ inputs.port }}\"}") BODY=$(echo "$RESPONSE" | head -n -1) CODE=$(echo "$RESPONSE" | tail -n1) echo "$BODY" if [ "$CODE" != "200" ]; then echo "::error::Deploy basarisiz (HTTP $CODE): $BODY" exit 1 fi