diff --git a/compose/action.yml b/compose/action.yml new file mode 100644 index 0000000..cfb4b7f --- /dev/null +++ b/compose/action.yml @@ -0,0 +1,57 @@ +name: 'Deploy Compose App to rack-server' +description: 'DNS kaydini deploy-panel API si uzerinden garanti eder, Traefik ayarlarini otomatik ekler ve "docker compose up -d --build" calistirir.' + +inputs: + hostname: + description: 'Uygulamanin public hostname i (orn. myapp.akalan.dev)' + required: true + service: + description: 'docker-compose.yml icinde disari acilacak servisin adi (orn. web)' + required: true + port: + description: 'O serviste uygulamanin dinledigi port' + required: false + default: '80' + 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: DNS kaydini garanti et (panel API uzerinden) + shell: bash + env: + PANEL_TOKEN: ${{ inputs.panel_token }} + run: | + set -e + RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "${{ inputs.panel_url }}/api/ensure-dns" \ + -H "Authorization: Bearer $PANEL_TOKEN" -H "Content-Type: application/json" \ + -d "{\"hostname\":\"${{ inputs.hostname }}\"}") + BODY=$(echo "$RESPONSE" | head -n -1) + CODE=$(echo "$RESPONSE" | tail -n1) + echo "$BODY" + if [ "$CODE" != "200" ]; then + echo "::error::DNS ensure basarisiz (HTTP $CODE): $BODY" + exit 1 + fi + + - name: Traefik override dosyasi olustur + shell: bash + env: + SERVICE: ${{ inputs.service }} + HOSTNAME: ${{ inputs.hostname }} + PORT: ${{ inputs.port }} + ROUTER_NAME: ${{ github.repository }} + run: | + ROUTER_NAME="${ROUTER_NAME##*/}" + export ROUTER_NAME + bash ${{ github.action_path }}/../scripts/gen-override.sh + + - name: docker compose up -d --build + shell: bash + run: docker compose -f docker-compose.yml -f .deploy-toolkit-override.yml up -d --build