Skip to content

About

Unofficial: secure deployments to MyDevil.net via rsync over SSH, from any CI or your terminal. Atomic releases, instant rollback, zero npm dependencies.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

mydevil-deploy // rsync ssh atomic releases

Created and maintained by hebda.dev.

MyDevil Deploy

English | Polski

Unofficial. This project is not created, endorsed, or supported by MyDevil.net.

Referral links: links to MyDevil.net in this documentation are referral links — if you sign up through them, the author of this project receives a commission, and you get a 20% discount on your new account.

Version 0.x. Before 1.0, setting names and default values may still change, but never silently: every such change is listed under Breaking in the changelog, and a renamed setting fails with an error that names the new one.

Secure deployments to MyDevil.net hosting via rsync over SSH, with atomic releases, commands before and after the new files go live, and application restart (devil www restart). One tool, wherever your code is built:

  • GitHub Actions: the action hebda-dev/mydevil-deploy, pinned to a commit.
  • GitLab CI, Forgejo/Gitea Actions and Bitbucket Pipelines: a ready CI file that runs the command-line tool (CI platforms).
  • Your own machine or any other CI: the command-line tool, npx mydevil-deploy (Command-line tool).

All of them take the same settings, optionally from one mydevil-deploy.json file, and mydevil-deploy init sets up a project for any of them.

Zero npm dependencies. The code uses only Node.js built-in modules and the system ssh and rsync binaries. There is no build step and no bundled dist/: the code you audit in src/ is exactly the code that runs, in the action and in the npm package alike.

Features

  • Fast, precise sync: rsync over SSH transfers only files whose content changed. delete, exclude and dry_run (which shows the whole plan) are supported, .git is never uploaded, and an upload guard stops files such as .env, *.pem or *.sql from landing in a public directory.
  • Atomic deployments: every deployment is a new release, prepared in <target>.releases/<id> and swapped in with two renames. Earlier releases stay there (keep_releases) for an instant rollback, and excluded paths such as uploads/ stay on the server, just like in the default mode.
  • Database migrations with automatic backup: works with any migration tool (Prisma, Knex, Laravel, Django, Alembic, …). MySQL and PostgreSQL are dumped right before migrations, and database passwords never leave the server.
  • Built for MyDevil: devil www restart for Node.js, Python and Ruby apps, plus a health check request that also spares the first visitor the cold start.
  • Release-based deploys: an example workflow deploys when you publish a GitHub release; redeploying an older tag is your rollback.
  • Set up in one command: init detects the project, picks a preset (Laravel, WordPress, Django, Node.js, PHP, static sites), writes the config file and the CI file for your platform, and can create a restricted deploy key and store it as the CI secret.
  • Checks before you deploy: check and doctor verify the settings, the runtime versions, the pins and, read-only, the server.
  • Security first:
    • zero npm dependencies,
    • strict host key checking,
    • no shell on the runner,
    • the key is masked in logs and removed after the run,
    • workflow-command injection through logs is blocked,
    • every input is validated against an allowlist.
  • Tested end to end: unit tests, local end-to-end tests with real rsync, and integration tests on a real GitHub runner that automatically check the logs for leaks, including a run of the GitLab CI template in its own image.

Usage

The quickest start, in your project's directory: init asks only what it cannot find out, reads the server over your own SSH access and shows every change before making it.

npx --yes mydevil-deploy@0.1.2 init

GitHub Actions

Without init: create a deploy key, verify the server's host key and store both as environment secrets (see Quick start), then add a workflow:

# .github/workflows/deploy.yml
name: deploy

on:
  push:
    branches: [main]

permissions:
  contents: read

concurrency:
  group: deploy-production
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: production
      url: ${{ steps.deploy.outputs.url }}
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false

      # No build here: code from npm packages must never run in the job that holds the deploy key.
      # To build first, use a separate job, as in "Example: deploy on GitHub release" below.

      - id: deploy
        uses: hebda-dev/mydevil-deploy@<full-commit-sha>
        with:
          host: s1.mydevil.net
          username: ${{ secrets.MYDEVIL_USER }}
          ssh_private_key: ${{ secrets.MYDEVIL_SSH_KEY }}
          known_hosts: ${{ secrets.MYDEVIL_KNOWN_HOSTS }}
          source: .
          target: domains/example.com/public_nodejs
          exclude: |
            .github/
            node_modules/
            .env
          prepare_command: /usr/local/bin/npm24 ci --omit=dev
          domain: example.com

Deployments are atomic by default. The first one into a site that already has files stops and lists them: add what the server must keep to exclude, or set adopt: true once (a copy is kept). With domain, the tool checks the website with devil www list before uploading, restarts Node.js, Python and Ruby apps, and requests https://example.com/ afterwards. For a static/PHP site use target: domains/example.com/public_html (or leave target out: domain finds it); PHP sites are not restarted. npm24 stands for the npm of the Node.js version you chose for the site in the MyDevil panel (why).

GitLab CI, Forgejo and Bitbucket

init --ci gitlab (or forgejo, bitbucket) writes the CI file, and the deploy key is a protected CI variable. The files and how to set them up by hand: CI platforms.

From your machine

npx --yes mydevil-deploy@0.1.2 --env production

The command-line tool reads mydevil-deploy.json and connects with your own SSH setup (agent, ~/.ssh/config): see Command-line tool.

The full documentation is in docs/ and online at https://mydevil-deploy.hebda.dev.

Documentation

Page What it covers
Quick start deploy key, host key, secrets and your first workflow
Deploy on GitHub release build and deploy in separate jobs, release tags, rollback
Atomic deployments near zero-downtime releases in <target>.releases
Rollback make an earlier release live again, from the CLI or a workflow
Database migrations migrations with an automatic MySQL/PostgreSQL backup
Inputs every input and output, order of steps, limitations
Command-line tool npx deploys from your machine or another CI, with the same validation
Config file one JSON file with environments, a schema for editors, and where each value comes from
Presets ready settings for Laravel, WordPress, Django, Node.js, PHP and static sites
CI platforms GitHub Actions, GitLab CI, Forgejo/Gitea Actions and Bitbucket Pipelines
Checks check and doctor: the settings, versions and server before a deployment
Security model what the tool guarantees and how to harden the deploy key
Documentation site how this site is built and deployed with the action itself
Development tests, integration tests and the log-leak check

Supporting the project

This project is free and maintained in spare time. If it saves you time, you can help keep it going:

  • Star the repository — it helps other MyDevil users find it.
  • Create your MyDevil.net account through this referral link. You get a 20% discount on your new account, and the project receives a commission at no extra cost to you.
  • Report bugs and suggest features in Issues, and tell how it went with the Feedback on 0.x form. Security issues go through private reporting instead.
  • Contribute: pull requests are welcome; CONTRIBUTING.md has the rules and how to run the tests.
  • Share it with others who deploy to MyDevil.net.

License

MIT

About

Unofficial: secure deployments to MyDevil.net via rsync over SSH, from any CI or your terminal. Atomic releases, instant rollback, zero npm dependencies.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages