Skip to content

Commit

Permalink
i12e (CI): trigger dependant builds
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfaust committed Apr 9, 2019
1 parent f5b667f commit 7399cd5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ jobs:
script:
- env SQLITE3_URL=$SQLITE3_URL crystal spec db_spec/sqlite3
- stage: Deployment
before_install:
- nvm install 9
- npm install shelljs got
script:
- crystal docs
after_success:
- node .travis/trigger-dependant-builds.js
deploy:
provider: pages
skip_cleanup: true
Expand Down
57 changes: 57 additions & 0 deletions .travis/trigger-dependant-builds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env node
"use strict";

const shell = require("shelljs");
const path = require("path");
const got = require("got");

console.log("Fetching Git commit hash...");

const gitCommitRet = shell.exec("git rev-parse HEAD", {
cwd: path.join(__dirname, "..")
});

if (0 !== gitCommitRet.code) {
console.error("Error getting git commit hash");
process.exit(-1);
}

const gitCommitHash = gitCommitRet.stdout.trim();

const gitSubjectRet = shell.exec(`git show -s --format=%s ${gitCommitHash}`, {
cwd: path.join(__dirname, "..")
});

const gitCommitSubject = gitSubjectRet.stdout.trim();

const triggerBuild = (username, repo, branch) => {
console.log(`Triggering ${username}/${repo}@${branch}...`);

got.post(`https://api.travis-ci.org/repo/${username}%2F${repo}/requests`, {
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Travis-API-Version": "3",
"Authorization": `token ${process.env.TRAVIS_API_TOKEN}`,
},
body: JSON.stringify({
request: {
message: `onyx-sql@${gitCommitHash.substring(0, 7)} ${gitCommitSubject}`,
branch: branch,
config: {
env: `ONYX_SQL_COMMIT=${gitCommitHash}`
}
},
}),
})
.then(() => {
console.log(`Triggered ${username}/${repo}@${branch}`);
})
.catch((err) => {
console.error(err);
process.exit(-1);
});
};

triggerBuild("vladfaust", "crystalworld", "master");
triggerBuild("vladfaust", "onyx-todo-json-api", "part-2");

0 comments on commit 7399cd5

Please sign in to comment.