From b4f028d18475acb253f08b05bf064c1dc91f7fde Mon Sep 17 00:00:00 2001 From: Julian <40327956+Archi657@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:01:45 +0100 Subject: [PATCH 1/4] force delete project Delete docker project before deploying allowing to start with a fresh enviroment. --- README.md | 1 + action.yaml | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c356290..8155f3a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ jobs: | `project-name` | Name of the project for identification | No | `${{ github.repository }}` | | `environment-variables` | Environment variables (KEY=value format, newline separated) | No | - | | `docker-compose-path` | Path to docker-compose.yml file (will be detected automatically otherwise) | No | - | +| `force-delete-container`| Delete original project if exists, to allow a clean deployment | No | - false | ## Setting up Secrets diff --git a/action.yaml b/action.yaml index d2cf01a..3f334a5 100644 --- a/action.yaml +++ b/action.yaml @@ -25,6 +25,10 @@ inputs: description: 'Relative path to docker-compose.yml file from repository root' required: false default: "" + force-delete-project: + description: 'Force delete the running project if exists, before deployment' + required: false + default: "false" runs: using: composite @@ -52,6 +56,58 @@ runs: echo "url=$URL" >> $GITHUB_OUTPUT + - name: Delete project if force-delete-project enabled + if: inputs.force-delete-project == 'true' + shell: bash + run: | + echo "đŸ—‘ī¸ Force delete enabled. Attempting to delete running container..." + echo "đŸ“Ļ Project: ${{ inputs.project-name }}" + echo "đŸ–Ĩī¸ VM: ${{ inputs.virtual-machine }}" + + RESPONSE=$(curl -s -w "\n%{http_code}" -X DELETE \ + -H "Authorization: Bearer ${{ inputs.api-key }}" \ + -H "Content-Type: application/json" \ + "https://developers.hostinger.com/api/vps/v1/virtual-machines/${{ inputs.virtual-machine }}/docker/${{ inputs.project-name }}/down") + + # Extract response body and status code + HTTP_BODY=$(echo "$RESPONSE" | sed '$d') + HTTP_STATUS=$(echo "$RESPONSE" | tail -n1) + + # Check if API response + if [ "$HTTP_STATUS" -ge 200 ] && [ "$HTTP_STATUS" -lt 300 ]; then + echo "✅ Container deleted successfully!" + else + echo "âš ī¸ Failed to delete container with status code: $HTTP_STATUS" + + # Try to parse error message + if command -v jq &> /dev/null && [ -n "$HTTP_BODY" ]; then + ERROR_MSG=$(echo "$HTTP_BODY" | jq -r '.message' 2>/dev/null || echo "") + if [ -n "$ERROR_MSG" ]; then + echo "Error: $ERROR_MSG" + else + echo "$HTTP_BODY" + fi + else + echo "$HTTP_BODY" + fi + + case $HTTP_STATUS in + 401) + echo "🔑 Hint: Check if your API key is valid and has the necessary permissions." + ;; + 404) + echo "🔍 Hint: Verify that the virtual machine ID '${{ inputs.virtual-machine }}' exists." + ;; + 422) + echo "âš ī¸ Hint: The request data might be invalid. Check your docker-compose file format." + ;; + 500|502|503) + echo "🔧 Hint: Server error. The Hostinger API might be experiencing issues. Try again later." + ;; + esac + echo "â„šī¸ Continuing with deployment anyway..." + fi + - name: Deploy to Hostinger shell: bash run: | @@ -127,4 +183,4 @@ runs: echo "đŸ–Ĩī¸ VM: ${{ inputs.virtual-machine }}" echo "🔄 Commit: ${{ github.sha }}" echo "👤 Triggered by: ${{ github.actor }}" - echo "======================================" \ No newline at end of file + echo "======================================" From 8c267fc3a6287bc63eca41659f550b28dd0aed29 Mon Sep 17 00:00:00 2001 From: Julian <40327956+Archi657@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:18:19 +0100 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8155f3a..065c7b0 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ jobs: | `project-name` | Name of the project for identification | No | `${{ github.repository }}` | | `environment-variables` | Environment variables (KEY=value format, newline separated) | No | - | | `docker-compose-path` | Path to docker-compose.yml file (will be detected automatically otherwise) | No | - | -| `force-delete-container`| Delete original project if exists, to allow a clean deployment | No | - false | +| `force-delete-project` | Delete original project if exists, to allow a clean deployment | No | - false | ## Setting up Secrets From c4daacb6837c08f1c7abf765706f2bc68346cce2 Mon Sep 17 00:00:00 2001 From: Julian <40327956+Archi657@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:43:04 +0100 Subject: [PATCH 3/4] Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 065c7b0..7918407 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ jobs: | `project-name` | Name of the project for identification | No | `${{ github.repository }}` | | `environment-variables` | Environment variables (KEY=value format, newline separated) | No | - | | `docker-compose-path` | Path to docker-compose.yml file (will be detected automatically otherwise) | No | - | -| `force-delete-project` | Delete original project if exists, to allow a clean deployment | No | - false | +| `force-delete-project` | Delete original project if exists, to allow a clean deployment | No | `false` | ## Setting up Secrets From a992d7479745fbba613f0cf6271317df80e6aae7 Mon Sep 17 00:00:00 2001 From: Julian <40327956+Archi657@users.noreply.github.com> Date: Tue, 27 Jan 2026 17:32:47 +0100 Subject: [PATCH 4/4] Update action name to include 'Project Down' --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 3f334a5..6668cad 100644 --- a/action.yaml +++ b/action.yaml @@ -1,4 +1,4 @@ -name: Deploy on Hostinger VPS +name: Deploy on Hostinger VPS Project Down author: Hostinger description: Deploy your dockerized application on Hostinger VPS instance