Skip to content

EXPERIMENTAL: Otsukai: Simple, and Easy to use deployment application for your servers.

License

Notifications You must be signed in to change notification settings

mika-sandbox/otsukai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

fd03f9e · Sep 6, 2024

History

37 Commits
Aug 29, 2024
Aug 29, 2024
Sep 1, 2024
Sep 1, 2024
Sep 6, 2024
Aug 29, 2024
Sep 2, 2024
Aug 27, 2024
Aug 17, 2024
Sep 6, 2024
Sep 1, 2024
Aug 29, 2024
Sep 1, 2024

Repository files navigation

Otsukai

Otsukai: Simple, and Easy to use deployment application for your servers.

Installation

From Source

$ git clone https://github.com/mika-f/otsukai
$ cd otsukai
$ go install

From Binary

Download the binary from the releases page and place it in your $PATH.

Usage

At the first time, you need to create a configuration file.

NOTE The deployment recipe has subset of Ruby, but not run as Ruby.

# default target host, with user
set target: { host: "yuuka.natsuneko.net", user: "ubuntu" }

task :deploy do
  if changed(path: "/path/to/docker-compose.yml", from: :last_commit)
    # run with sudo
    run_with :sudo do
      # run docker compose down on remote
      run remote: "docker compose down -f /remote/path/to/docker-compose.yml"

      # copy file/directory from local (/path/to/docker-compose.yml) to remote (/home/ubuntu/docker-compose.yml)
      copy to: :remote, local: "/path/to/docker-compose.yml", remote: "/home/ubuntu/docker-compose.yml"

      # run docker compose on remote
      run remote: "docker compose up -d -f /remote/path/to/docker-compose.yml"
    end
  end
end

Then, you can deploy your application by running the following command.

# check syntax before deploy
$ otsukai test --recipe examples/docker-compose/otsukai.rb

# deploy
$ otsukai run --recipe examples/docker-compose/otsukai.rb

# deploy (dry-run)
$ otsukai run --recipe examples/docker-compose/otsukai.rb --dry-run

Functions

set (local func)

Set a variable value. Example:

set remote: { host: "yuuka.natsuneko.net", user: "ubuntu" }
set default: :deploy
set app_root: "/usr/local/"

The following variables are specialized:

  • remote: { host: string, user: string }
  • timeout: number (default: 10)

task (local func)

Define a task with name. Example:

# define `deploy` task
task :deploy do
  # ...
end

# define `rollback` task
task :rollback do
  # ...
end

changed (local func)

Check the specified path has changed from specified refs.

changed(path: "/path/to/file", commit_from: :last_commit, commit_to: :head) # returns bool

the commit_from supports the following args:

  • :last_commit : the specified file is changed in last commit
  • :fetch_commit : the specified file is changed in remote fetched commit (ref: git-rev-parse#FETCH_HEAD)
  • :before_merge : the specified file is changed in before merged commit (ref: git-rev-parse#ORIG_HEAD)
  • :after_merge : the specified file is changed in merged commit(s) (ref: git-rev-parse#MERGE_HEAD)

the commit_to supports the following args:

  • Not Yet Implemented

copy (local / remote func)

Copy file/directory between from local/remote to remote/local.

copy(to: :remote, local: "/path/to/file", remote: "/path/to/dest")
copy(to: :local, remote: "/path/to/file", local: "/path/to/dest", is_dir: true)

the to supports the following args:

  • :remote : copy from local to remote
  • :local : copy from remote to local

the local and remote is path of the file or directory. if the directory is specified, copy recursively.

the is_dir is required for to: :local, and default is false.

run (local / remote func)

Run commands in local/remote.

run(remote: "echo 'Hello, World'")
run(local:  "echo 'Hello, World'")

task_success (local func)

Return true when the last task is successful.

task :deploy do
  # ...
end

hook after: :deploy do
  if task_success
    run # ...
  end
end

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

EXPERIMENTAL: Otsukai: Simple, and Easy to use deployment application for your servers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages