GitHub Actions
The CLI talks to the management API over HTTPS using an API key. Store the key as a GitHub Actions secret and call simpledeploy apply from a workflow.
Prerequisites
Section titled “Prerequisites”- A SimpleDeploy server reachable from GitHub runners (or a self-hosted runner inside your network).
- An API key with deploy permission. Generate it under
Settings -> API keysin the dashboard. - A
docker-compose.ymlchecked into the repo.
Secrets to set
Section titled “Secrets to set”| Secret | Value |
|---|---|
SIMPLEDEPLOY_URL |
https://deploy.example.com |
SIMPLEDEPLOY_TOKEN |
the API key |
GHCR_USERNAME |
your GitHub username |
GHCR_TOKEN |
a PAT with write:packages scope (or use GITHUB_TOKEN) |
Workflow
Section titled “Workflow”name: Build and deploy
on: push: branches: [main]
jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Log in to GHCR uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 with: context: . push: true tags: | ghcr.io/${{ github.repository }}:${{ github.sha }} ghcr.io/${{ github.repository }}:latest
- name: Install SimpleDeploy CLI env: SD_VERSION: "1.4.8" # x-release-please-version run: | base="https://github.com/vazra/simpledeploy/releases/download/v${SD_VERSION}" file="simpledeploy_${SD_VERSION}_linux_amd64.tar.gz" curl -fsSLO "${base}/${file}" curl -fsSLO "${base}/checksums.txt" # Fails the step unless the tarball matches the release's checksums.txt. grep " ${file}$" checksums.txt | sha256sum -c - tar xzf "$file" simpledeploy sudo install -m 0755 simpledeploy /usr/local/bin/simpledeploy simpledeploy version
- name: Configure remote context env: SD_URL: ${{ secrets.SIMPLEDEPLOY_URL }} SD_TOKEN: ${{ secrets.SIMPLEDEPLOY_TOKEN }} run: | simpledeploy context add prod \ --url "$SD_URL" \ --token "$SD_TOKEN" simpledeploy context use prod
- name: Apply compose file run: | # Substitute the freshly pushed image tag. sed -i "s|IMAGE_TAG|${{ github.sha }}|g" docker-compose.yml simpledeploy apply -f docker-compose.yml --name myapp --waitCompose with a tagged image
Section titled “Compose with a tagged image”services: web: image: ghcr.io/your-org/your-repo:IMAGE_TAG labels: simpledeploy.domain: app.example.com ports: - "3000"sed rewrites IMAGE_TAG to the commit SHA before apply. The server pulls the new image, redeploys, and reports back. --wait blocks until the deploy is healthy or fails.
Rollback
Section titled “Rollback”simpledeploy versions <app> lists previous deploys. Roll back with:
- name: Rollback to previous version run: simpledeploy rollback myapp --to v42Wire this to a workflow_dispatch trigger so you can roll back manually from the Actions tab.
- The CLI is pinned to a release with
SD_VERSION. The step downloads that release’schecksums.txtand checks the tarball against it, so a corrupted or truncated download fails the step (run scripts usebash -e). To upgrade, bumpSD_VERSION; there is no checksum to copy by hand. - The example pins every action to a full commit SHA, with the release tag in a trailing comment. Keep that pattern when you add or bump actions; Dependabot and Renovate update the SHA and the comment together.
- Use environments (Production, Staging) and store separate
SIMPLEDEPLOY_URL/SIMPLEDEPLOY_TOKENsecrets per environment. - For matrix deploys to many servers, loop over an array of context names rather than duplicating steps.