- Notifications
You must be signed in to change notification settings - Fork4
Install and update WordPress themes and plugins directly from your Git repository via GitHub, Gitlab or Bitbucket.
License
nico-martin/git-installer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Install and update WordPress themes and plugins directly from your Git repository via GitHub, Gitlab or Bitbucket.
"Git Installer" works with public and private repositories, different branches, subdirectories and even allows automatedupdates via webhooks. Furthermore, plugins or themes are automatically recognised and validated and it also supportsmust use plugins and multisite installations.
https://update.git-installer.com/zip.php?release=latest
Feature | Status |
---|---|
Install and update Plugins from Git repositories | ✅ |
Provider | |
- GitHub | ✅ |
- Gitlab | ✅ |
- Bitbucket | ✅ |
Webhook updates | ✅ |
Integrated WordPress update process View pending updates directly in the WordPress overview and update them individually or as a bulk update. | ✅ |
Private Repositories | ✅ |
Must Use Plugin support https://wordpress.org/support/article/must-use-plugins/ | ✅ |
Branches | any branch |
Multisite | ✅ |
Install from subdirectories | ✅ |
Check directory Validates a Repository and checks wether a valid WordPress theme or plugin is found. | ✅ |
Postupdate Hooks Run your composer, NPM or other builds after the update | ✅ |
"Git Installer" enables updates to be carried out automatically via a webhook. For each package, a "Webhook Update URL"is created, which must be deposited with the respective provider.
Repository -> Settings -> Webhooks -> Add webhook:
- Payload URL: the Webhook Update URL
- Content type: application/x-www-form-urlencoded
- Secret: none
- Which events would you like to trigger this webhook?: Just the push event
Repository -> Settings -> Webhooks:
- URL: the Webhook Update URL
- Trigger: Push events (Branch name should match the branch you are using, blank works as well)
- Secret token: none
- SSL verification: checked
Repository -> Repository settings -> Workflow -> Webhooks -> Add webhook:
- Title: choose your own
- URL: the Webhook Update URL
- Active: checked
- SSL/TLS: unchecked
- Triggers: Repository > Push
An action that runs after a successful update.
add_action('shgi/GitPackages/updatePackage/success',function($packageKey,$ref,$prevVersion,$nextVersion){// $packageKey: string = the key of the plugin or theme. Usually the name of the github repo// $ref: string = key of the "refOption" defined in `shgi/UpdateLog/refOptions`// $prevVersion: string = version before the update// $nextVersion: string = version after the update},20,4);
An action that runs after a failed update.
add_action('shgi/GitPackages/updatePackage/error',function($packageKey,$ref,$reason){// $packageKey: string = the key of the plugin or theme. Usually the name of the github repo// $ref: string = key of the "refOption" defined in `shgi/UpdateLog/refOptions`// $reason: WP_Error = a reason why the update failed},20,3);
Activate "Must Use Plugin" support
add_filter('shgi/Repositories/MustUsePlugins','__return_true');
Now you are able to select the target folder for your plugin before the installation.
Updates are usually done via a REST endpoint:
`${REST_API}/git-installer/v1/git-packages-deploy/${REPOSITORY_SLUG}/?key=${REPOSITORY_SECRET}`
This endpoint accepts an additional GET parameter calledref
which is used for logging.
`${REST_API}/git-installer/v1/git-packages-deploy/${REPOSITORY_SLUG}/?key=${REPOSITORY_SECRET}&ref=webhook-update`
If needed, further refferer values can be added via a filter.
add_filter('shgi/UpdateLog/refOptions',function($refs){/** * Initial values: * [ * 'install' => __('Install', 'shgi'), * 'webhook-update' => __('webhook', 'shgi'), * 'update-trigger' => __('update button', 'shgi') * ] */$refs['my-ref'] ='My custom trigger';return$refs;});
add_filter('shgi/Hooks/PostupdateHooks',function($hooks){$hooks['my-custom-hook'] = ['title' =>'My Custom Hook','description' =>'Describe what the hook will do','function' =>function($package){// this function will run after a successfull update// $package is the full Package-Object },'check' =>function(){// returns a boolean wether the system supports this hook (for example if npm/composer is installed)returntrue; } ];return$hooks;});
By default, git-installer uses thecomposer
-alias to run composer. If your configuration does not support aliases, you can also define aSHGI_COMPOSER_COMMAND
constant in thewp-config.php
:
define('SHGI_COMPOSER_COMMAND','~/bin/composer');
Nico Martin
nico.dev -github.com/nico-martin
About
Install and update WordPress themes and plugins directly from your Git repository via GitHub, Gitlab or Bitbucket.