{"id":5831,"date":"2025-09-19T11:58:23","date_gmt":"2025-09-19T11:58:23","guid":{"rendered":"https:\/\/www.hostinger.com\/support\/?p=5831"},"modified":"2025-09-19T12:29:43","modified_gmt":"2025-09-19T12:29:43","slug":"deploy-to-hostinger-vps-using-github-actions","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/deploy-to-hostinger-vps-using-github-actions\/","title":{"rendered":"Deploy to Hostinger VPS using GitHub Actions"},"content":{"rendered":"<p>With the <strong>Deploy to Hostinger VPS<\/strong> <a href=\"https:\/\/github.com\/marketplace\/actions\/deploy-on-hostinger-vps\" target=\"_blank\" rel=\"noopener\">GitHub Action<\/a>, you can automatically deploy your Docker applications to a Hostinger VPS directly from your repository. Every push to your branch can trigger a deployment, making CI\/CD efficient and straightforward.<\/p><h2 id=\"prerequisites\">Prerequisites<\/h2><ul>\n<li>A <a href=\"https:\/\/www.hostinger.com\/vps\/docker-hosting\">Hostinger VPS with a Docker template installed<\/a>.<\/li>\n<li>A <code>docker-compose.yml<\/code> file in your repository.<\/li>\n<li>A Hostinger API key (generated in <a class=\"decorated-link cursor-pointer\" href=\"https:\/\/hpanel.hostinger.com\/profile\/api\" target=\"_new\" rel=\"noopener\">hPanel<\/a>).<\/li>\n<li>Your VPS <strong data-start=\"695\" data-end=\"717\">Virtual Machine ID<\/strong> (found in the VPS overview URL or default hostname).<\/li>\n<li data-start=\"773\" data-end=\"842\">\n<p data-start=\"775\" data-end=\"842\">(Optional) GitHub Personal Access Token for private repositories.<\/p>\n<\/li>\n<\/ul><h2 id=\"secrets\">Setting up GitHub Secrets and Variables<\/h2><ol data-start=\"893\" data-end=\"1236\">\n<li data-start=\"893\" data-end=\"956\">\n<p data-start=\"896\" data-end=\"956\"><strong data-start=\"896\" data-end=\"926\">Generate Hostinger API Key<\/strong> in hPanel &rarr; <a href=\"https:\/\/hpanel.hostinger.com\/profile\/api\" target=\"_blank\" rel=\"noopener\"><em data-start=\"939\" data-end=\"953\">API settings<\/em><\/a>.<\/p>\n<\/li>\n<li data-start=\"957\" data-end=\"1027\">\n<p data-start=\"960\" data-end=\"1027\"><strong data-start=\"960\" data-end=\"974\">Find VM ID<\/strong>: e.g. <code data-start=\"981\" data-end=\"1004\">srv123456.hstgr.cloud<\/code> &rarr; VM ID is <code data-start=\"1016\" data-end=\"1024\">123456<\/code>.<\/p>\n<\/li>\n<li data-start=\"1028\" data-end=\"1236\">\n<p data-start=\"1031\" data-end=\"1113\">In your GitHub repository, go to <strong data-start=\"1064\" data-end=\"1110\">Settings &rarr; Secrets and variables &rarr; Actions<\/strong>.<\/p>\n<ul data-start=\"1117\" data-end=\"1236\">\n<li data-start=\"1117\" data-end=\"1152\">\n<p data-start=\"1119\" data-end=\"1152\">Add secret: <code data-start=\"1131\" data-end=\"1150\">HOSTINGER_API_KEY<\/code><\/p>\n<\/li>\n<li data-start=\"1156\" data-end=\"1197\">\n<p data-start=\"1158\" data-end=\"1197\">(Optional) Add secret: <code data-start=\"1181\" data-end=\"1195\">PERSONAL_ACCESS_TOKEN<\/code><\/p>\n<\/li>\n<li data-start=\"1201\" data-end=\"1236\">\n<p data-start=\"1203\" data-end=\"1236\">Add variable: <code data-start=\"1217\" data-end=\"1234\">HOSTINGER_VM_ID<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol><h2 id=\"public\">Example workflow (public repository)<\/h2><pre>name: Deploy to Hostinger\r\n\r\non:\r\npush:\r\nbranches: [ main ]\r\n\r\njobs:\r\ndeploy:\r\nruns-on: ubuntu-latest\r\nsteps:\r\n- uses: actions\/checkout@v5\r\n\r\n- name: Deploy to Hostinger\r\nuses: hostinger\/deploy-action@v1\r\nwith:\r\napi-key: ${{ secrets.HOSTINGER_API_KEY }}\r\nvirtual-machine: ${{ vars.HOSTINGER_VM_ID }}<\/pre><h2 id=\"private\">Example workflow (private repo with environment variables)<\/h2><pre>name: Deploy to Hostinger\r\n\r\non:\r\npush:\r\nbranches: [ main, production ]\r\n\r\njobs:\r\ndeploy:\r\nruns-on: ubuntu-latest\r\nsteps:\r\n- uses: actions\/checkout@v5\r\n\r\n- name: Deploy to Hostinger\r\nuses: hostinger\/deploy-action@v1\r\nwith:\r\napi-key: ${{ secrets.HOSTINGER_API_KEY }}\r\nvirtual-machine: ${{ vars.HOSTINGER_VM_ID }}\r\nproject-name: my-awesome-app\r\npersonal-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}\r\ndocker-compose-path: docker\/docker-compose.yml\r\nenvironment-variables: |\r\nNODE_ENV=production\r\nAPI_URL=https:\/\/api.example.com\r\nDATABASE_URL=${{ secrets.DATABASE_URL }}<\/pre><p>Once configured, every push or tag can automatically redeploy your application on your Hostinger VPS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the Deploy to Hostinger VPS GitHub Action, you can automatically deploy your Docker applications to a Hostinger VPS directly from your repository. Every push&#8230;<\/p>\n","protected":false},"author":386,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[297],"tags":[],"class_list":["post-5831","post","type-post","status-publish","format-standard","hentry","category-docker-manager"],"hreflangs":[],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/5831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/386"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=5831"}],"version-history":[{"count":5,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/5831\/revisions"}],"predecessor-version":[{"id":5836,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/5831\/revisions\/5836"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=5831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=5831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=5831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}