Skip to content

Instantly share code, notes, and snippets.

@marcelosousa
Last active December 4, 2019 15:00
Show Gist options
  • Save marcelosousa/916449bbe31a98511e231c1fb4e8556e to your computer and use it in GitHub Desktop.
Save marcelosousa/916449bbe31a98511e231c1fb4e8556e to your computer and use it in GitHub Desktop.
Google cloud function deployment with protobot
const { createProbot } = require('probot');
async function dec() {
const kms = require('@google-cloud/kms');
const client = new kms.KeyManagementServiceClient();
const ciphertext = "asdadkjasdCASDASdlkjasdasd11";
const name = 'projects/PROJECT-ID/locations/global/keyRings/KEY-NAME/cryptoKeys/CRYPTO-NAME';
const [result] = await client.decrypt({name, ciphertext});
return result.plaintext.toString('ascii');
}
appFn = app => {
console.log('Yay, the app was loaded!')
app.on('issues.opened', async context => {
const params = context.issue({ body: 'Hello World!' })
// Post a comment on the issue
return context.github.issues.createComment(params)
})
}
serverless = (apps, options) => {
return () => dec().then(function(sec) {
const opts = {
id: 11111,
secret: sec,
cert: ""
};
const probot = createProbot(opts)
apps = [].concat(apps) // Coerce to array
apps.forEach(a => probot.load(a))
return probot.server
})
}
exports.protobot = serverless(appFn)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment