Created
July 26, 2019 13:42
-
-
Save q-ode/76e92e169c0ceff38c6f526ce10e6262 to your computer and use it in GitHub Desktop.
Sample Broker Publishing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const pact = require('@pact-foundation/pact-node'); | |
const path = require('path'); | |
// Modify as required | |
const pactBroker = process.env.PACT_BROKER; | |
const pactBrokerToken = process.env.PACT_BROKER_TOKEN; | |
const gitBranch = process.env.CIRCLE_BRANCH; | |
const gitCommitHash = process.env.CIRCLE_SHA1; | |
const pactsDirectory = path.resolve(process.cwd(), '.contracts'); | |
if ( | |
fs.existsSync(pactsDirectory) && | |
fs.readdirSync(pactsDirectory).length > 0 | |
) { | |
pact | |
.publishPacts({ | |
pactBroker, | |
pactBrokerToken, | |
pactFilesOrDirs: [pactsDirectory], | |
consumerVersion: gitCommitHash, | |
tags: [gitBranch], | |
}) | |
.then(res => console.log(res)); | |
} else { | |
console.info('No Pacts available to be Published'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment