{"id":22665156,"url":"https://github.com/br0ken-/deploy-revision","last_synced_at":"2026-06-17T23:31:23.527Z","repository":{"id":56965830,"uuid":"81422463","full_name":"BR0kEN-/deploy-revision","owner":"BR0kEN-","description":"Deploy new code revision by performing operations from YAML playbooks","archived":false,"fork":false,"pushed_at":"2017-02-11T11:07:12.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T09:31:21.187Z","etag":null,"topics":["deploy","deployment","revisions","symfony-di-container","yaml"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BR0kEN-.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-09T07:29:56.000Z","updated_at":"2017-02-09T08:11:22.000Z","dependencies_parsed_at":"2022-08-21T06:10:22.380Z","dependency_job_id":null,"html_url":"https://github.com/BR0kEN-/deploy-revision","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BR0kEN-/deploy-revision","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BR0kEN-%2Fdeploy-revision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BR0kEN-%2Fdeploy-revision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BR0kEN-%2Fdeploy-revision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BR0kEN-%2Fdeploy-revision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BR0kEN-","download_url":"https://codeload.github.com/BR0kEN-/deploy-revision/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BR0kEN-%2Fdeploy-revision/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270831792,"owners_count":24653414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deploy","deployment","revisions","symfony-di-container","yaml"],"created_at":"2024-12-09T13:19:50.075Z","updated_at":"2026-06-17T23:31:23.495Z","avatar_url":"https://github.com/BR0kEN-.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploy Revision\n\nCreate a YAML playbook, define a code revision, specify upgrade path as commands for performing and distribute them between environments.\n\n[![Build Status](https://img.shields.io/travis/BR0kEN-/deploy-revision/master.svg?style=flat-square)](https://travis-ci.org/BR0kEN-/deploy-revision)\n[![Code coverage](https://img.shields.io/scrutinizer/coverage/g/BR0kEN-/deploy-revision/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/BR0kEN-/deploy-revision/?branch=master)\n[![Quality Score](https://img.shields.io/scrutinizer/g/BR0kEN-/deploy-revision.svg?style=flat-square)](https://scrutinizer-ci.com/g/BR0kEN-/deploy-revision)\n[![Coding standards](https://styleci.io/repos/81422463/shield?branch=master)](https://styleci.io/repos/81422463)\n[![Total Downloads](https://img.shields.io/packagist/dt/deploy/deploy-revision.svg?style=flat-square)](https://packagist.org/packages/deploy/deploy-revision)\n[![Latest Stable Version](https://poser.pugx.org/deploy/deploy-revision/v/stable?format=flat-square)](https://packagist.org/packages/deploy/deploy-revision)\n[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://packagist.org/packages/deploy/deploy-revision)\n\n## Installation\n\n```shell\ncomposer require deploy/deploy-revision:1.*\n```\n\n## Usage\n\nA view of deployment playbook.\n\n```yaml\ncommands:\n  # Commands below will be executed only if environment ID will match.\n  lush_website_at:\n    140:\n      - \"drush updb\"\n  # It's predefined namespace for commands which should be run everywhere.\n  global:\n    89:\n      - \"drush cc all\"\n    121:\n      - \"drush cc drush\"\n      - \"print bla bla\"\n\n# The order of commands for execution will looks like (only in case if current code version is lower than defined):\n# - For \"lush_website_at\" environment:\n#   - drush cc all - will be removed because we have \"drush updb\" (if logic like in \"filter()\" below will be implemented).\n#   - drush cc drush\n#   - print bla bla\n#   - drush updb\n#\n# - For \"global\" environment:\n#   - drush cc all\n#   - drush cc drush\n#   - print bla bla\n```\n\nInitialize the library at start.\n\n```php\nrequire_once 'vendor/autoload.php';\n\nuse DeployRevision\\DeployRevision;\n\n$deploy = new DeployRevision();\n```\n\nUse own YAML parser (if don't like Symfony).\n\n```php\nclass SpycYaml implements YamlInterface\n{\n    /**\n     * {@inheritdoc}\n     */\n    public function isAvailable()\n    {\n        return class_exists('Spyc');\n    }\n    \n    /**\n     * {@inheritdoc}\n     */\n    public function parse($content)\n    {\n        return \\Spyc::YAMLLoadString($content);\n    }\n\n    /**\n     * {@inheritdoc}\n     */\n    public function dump(array $content)\n    {\n        return \\Spyc::YAMLDump($content);\n    }\n}\n\n$deploy\n    -\u003egetContainer()\n    -\u003egetDefinition('deploy_revision.yaml')\n    -\u003esetClass(SpycYaml::class);\n```\n\nLook for `*.yml` playbooks inside a directory and for tasks in particular file.\n\n```php\n$deployment = $deploy-\u003egetWorker();\n// Read particular playbook.\n$deployment-\u003eread('../lush_deploy.yml');\n// Read playbooks within directory.\n$deployment-\u003eread('../lush_deploy');\n```\n\nSet an environment ID and/or path to file where revision ID should be stored (or duplicated, from DB for instance).\n\n```php\n$deployment = $deploy-\u003egetWorker('lush_website_at', 'private://revisions/revision');\n```\n\nFilter commands. Callback should return the command for deletion.\n\n```php\n$deployment-\u003efilter(function ($command, array $commands, callable $resolver) {\n    // Remove \"drush cc css-js\" since \"drush updb\" will do the job for it.\n    if ('drush cc css-js' === $command \u0026\u0026 isset($commands['drush updb'])) {\n        return $command; \n    }\n\n    // Remove all previously added \"drush cc all\" from the list if \"drush updb\" exists.\n    return $resolver(true, ['drush updb'], ['drush cc all'])\n        // Remove newly added \"drush cc all\" if \"drush updb\" in the list.\n        ?: $resolver(false, ['drush cc all'], ['drush updb']); \n});\n```\n\nRun deployment.\n\n```php\n$deployment-\u003edeploy(function ($command) {\n    $arguments = explode(' ', $command);\n    $program = array_shift($arguments);\n\n    switch ($program) {\n        case 'drush':\n            drush_invoke($program, $arguments);\n            break;\n\n        default:\n            printf('No handler found for the \"%s\" command.', $command);\n  }\n});\n```\n\nSave new revision ID.\n\n```php\n$deployment-\u003ecommit();\n```\n\n## Notes\n\n- All tasks from playbooks must be handled inside of deployment callback. This means that an implementation for recognizing the commands and for executing them should be done. Otherwise you'll not have any effect placing commands inside playbooks.\n- Tasks collected in order you running the `-\u003eread()` method. If you are reading `test1.yml` and `test2.yml` and both files have the same revision number inside, then commands from first file will be located above ones from second.\n\n  Reading of the directory will be done in alphabetical order. If multiple playbooks have the same revision numbers, then the only way you can affect on ordering - is to set file names in correct order.\n\n## Testing\n\nRun PHPUnit tests locally.\n\n```shell\n./bin/phpunit --coverage-text\n```\n\n### Scrutinizer CI\n\nUsed for generating [tests coverage](.scrutinizer.yml#L4-L10).\n\n### Travis CI\n\nUsed for running tests on [various PHP versions](.travis.yml#L4-L8).\n\n### Style CI\n\nUsed for verifying [coding standards](.styleci.yml#L1). Actually **Scrutinizer** doing this as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbr0ken-%2Fdeploy-revision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbr0ken-%2Fdeploy-revision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbr0ken-%2Fdeploy-revision/lists"}