Skip to content

Commit 6f21f78

Browse files
committed
Update hook docs
1 parent b87fbaf commit 6f21f78

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

docs/docs.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,8 @@ If you have deployed to the server, it involves a couple more steps.
817817
Hooks allow you to run a command or function before or after a CLI command is run. The config looks like:
818818

819819
```js
820+
const childProcess = require('child_process');
821+
820822
module.exports = {
821823
hooks: {
822824
hookName: {
@@ -829,28 +831,31 @@ module.exports = {
829831
'post.meteor.restart': {
830832
remoteCommand: 'docker logs --tail 50 app-name'
831833
},
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) {
833843
// Login to private Gitlab docker registry
834844
const config = api.getConfig();
835845
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) {
839850
throw new Error(
840851
'You must provide registry login details'
841852
);
842853
}
854+
843855
return api.runSSHCommand(
844856
config.servers.one,
845-
`docker login -u ${u} -p ${p} ${registry}`
857+
`docker login -u ${username} -p ${password} ${registry}`
846858
);
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');
854859
}
855860
}
856861
};

0 commit comments

Comments
 (0)