Push to main. GitHub Actions builds your Docker image, pushes it to a registry, then tells Serversinc to deploy it to your VPS.
This guide uses Docker Hub and a Docker image application in Serversinc. If you still need to configure an application for a registry image, start with the Docker image deployment instructions. The deploy trigger deploys the image tag already configured on your application; it doesn’t accept a tag from the workflow. If you need each workflow run to select a different tag, use an API token with the deployment API instead. See how to create an API token.
Set up the application and registry.
Create a Docker image application in Serversinc and connect it to the image repository you’ll push to. Set the application’s image tag to latest for this example. Don’t deploy it yet if the image isn’t in the registry.
In the application settings, open Deploy hooks and generate a trigger. Copy the deploy key and secret when shown. The secret is only shown once; store it in GitHub before closing the screen. For details, see the deploy trigger documentation.
In Docker Hub, create an access token for pushing images. In your GitHub repository, open Settings → Secrets and variables → Actions and add these repository secrets:
DOCKERHUB_USERNAME: your Docker Hub username.DOCKERHUB_TOKEN: the Docker Hub access token.SERVERSINC_DEPLOY_KEY: the deploy key from the application.SERVERSINC_DEPLOY_SECRET: the one-time secret from the application.
Build, push and trigger the deployment.
Add .github/workflows/deploy.yml to your repository:
name: Build and deploy
on: push: branches: [main]
permissions: contents: read
jobs: deploy: runs-on: ubuntu-latest steps: - name: Check out the repository uses: actions/checkout@v7
- name: Sign in to Docker Hub uses: docker/login-action@v4 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push the image env: IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/my-app:latest run: | docker build --tag "$IMAGE" . docker push "$IMAGE"
- name: Trigger deployment env: DEPLOY_KEY: ${{ secrets.SERVERSINC_DEPLOY_KEY }} DEPLOY_SECRET: ${{ secrets.SERVERSINC_DEPLOY_SECRET }} run: | curl --fail-with-body --silent --show-error \ --request POST "https://api.serversinc.io/v1/applications/${DEPLOY_KEY}/trigger" \ --header "X-Deploy-Secret: ${DEPLOY_SECRET}" \ --header "Accept: application/json"Replace my-app with the repository name of the image configured on your application. If you use a different registry, follow its GitHub Actions authentication instructions and make sure the Serversinc application can pull from it.
The trigger sends the request to deploy the application’s configured default image tag. A 201 response means Serversinc created a deployment; it doesn’t mean that deployment has finished. Check its status in the application’s Deployments view. A 401 response means the key or secret is unknown, missing or doesn’t match. Read the deploy trigger documentation for the response details and secret-rotation steps.
Keep the trigger secret safe.
Treat the deploy secret like a password: keep it in GitHub’s secret manager, never commit it to the repository, and don’t print it in workflow logs. The trigger is scoped to one application. Generating a replacement invalidates the previous secret, so update the GitHub secret before rerunning the workflow.
For a trigger that waits for deployment completion or selects a tag per run, see the deploy trigger documentation for the API-token alternative.