-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.js
35 lines (30 loc) · 1.15 KB
/
publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import path from "path";
import {Publisher} from '@pact-foundation/pact'
import childProcess from 'child_process'
const exec = command =>
childProcess
.execSync(command)
.toString()
.trim()
// Usually, you would just use the CI env vars, but to allow these examples to run from
// local development machines, we'll fall back to the git command when the env vars aren't set.
// TODO: Update these for your particular CI server
const gitSha = process.env.TRAVIS_COMMIT || exec("git rev-parse HEAD || echo LOCAL_DEV")
const branch = process.env.TRAVIS_BRANCH || exec("git rev-parse --abbrev-ref HEAD || echo LOCAL_DEV")
const opts = {
pactFilesOrDirs: [path.resolve(process.cwd(), "pacts")],
pactBroker: "https://eneskzlcn.pactflow.io",
pactBrokerToken: "L0IzB6WxiCRX7sEdAQoWlQ", // don't commit this!
consumerVersion: gitSha,
tags: [branch],
}
new Publisher(opts)
.publishPacts()
.then(() => {
console.log("Pact contract publishing complete!")
console.log("")
console.log("Head over to https://eneskzlcn.pactflow.io to see your published contracts.")
})
.catch(e => {
console.log("Pact contract publishing failed: ", e)
})