@@ -817,6 +817,8 @@ If you have deployed to the server, it involves a couple more steps.
817
817
Hooks allow you to run a command or function before or after a CLI command is run. The config looks like:
818
818
819
819
``` js
820
+ const childProcess = require (' child_process' );
821
+
820
822
module .exports = {
821
823
hooks: {
822
824
hookName: {
@@ -829,28 +831,31 @@ module.exports = {
829
831
' post.meteor.restart' : {
830
832
remoteCommand: ' docker logs --tail 50 app-name'
831
833
},
832
- ' pre.docker.setup' (api) {
834
+ ' pre.reconfig' (api) {
835
+ // Same api as is given to plugin command handlers
836
+ // If this runs asynchronous tasks, it needs to return a promise.
837
+ const gitHash = childProcess .execSync (' git rev-parse HEAD' ).toString ().trim ();
838
+
839
+ api .getSettings ();
840
+ api .settings .GIT_HASH = gitHash;
841
+ },
842
+ ' post.docker.setup' (api) {
833
843
// Login to private Gitlab docker registry
834
844
const config = api .getConfig ();
835
845
const registry = ' registry.gitlab.com' ;
836
- const u = process .env .REGISTRY_USERNAME ;
837
- const p = process .env .REGISTRY_PASSWORD ;
838
- if (! u || ! p) {
846
+ const username = process .env .REGISTRY_USERNAME ;
847
+ const password = process .env .REGISTRY_PASSWORD ;
848
+
849
+ if (! username || ! password) {
839
850
throw new Error (
840
851
' You must provide registry login details'
841
852
);
842
853
}
854
+
843
855
return api .runSSHCommand (
844
856
config .servers .one ,
845
- ` docker login -u ${ u } -p ${ p } ${ registry} `
857
+ ` docker login -u ${ username } -p ${ password } ${ registry} `
846
858
);
847
- },
848
- ' post.docker.setup' (api) {
849
- // Same api as is given to plugin command handlers
850
- // If this runs asynchronous tasks, it needs to return a promise.
851
- const config = api .getConfig ();
852
-
853
- return api .runSSHCommand (config .servers .one , ' docker --version' );
854
859
}
855
860
}
856
861
};
0 commit comments