From b1a767327d826492ff0e2e0685caeaa1aa9bb901 Mon Sep 17 00:00:00 2001 From: akalan Date: Wed, 23 Sep 2026 15:34:25 +0300 Subject: [PATCH] deploy-toolkit'ten tasindi --- action.yml | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 action.yml diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..b919230 --- /dev/null +++ b/action.yml @@ -0,0 +1,56 @@ +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