forked from deliverybot/deliverybot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
6,510 additions
and
402 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
production: | ||
auto_deploy_on: refs/heads/master | ||
environment: production | ||
required_contexts: ["build (10.x)", "deliverybot/promotion"] | ||
|
||
development: | ||
auto_deploy_on: refs/heads/master | ||
environment: development | ||
required_contexts: ["build (10.x)"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
name: Deploy | ||
|
||
on: ['deployment'] | ||
|
||
jobs: | ||
deployment: | ||
|
||
runs-on: 'ubuntu-latest' | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: 'use node 8.x' | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 8.x | ||
|
||
- name: 'deployment pending' | ||
uses: 'deliverybot/deployment-status@master' | ||
with: | ||
state: 'pending' | ||
token: '${{ github.token }}' | ||
|
||
- name: 'deploy' | ||
env: | ||
PRODUCTION_SA: '${{ secrets.PRODUCTION_SA }}' | ||
DEVELOPMENT_SA: '${{ secrets.DEVELOPMENT_SA }}' | ||
run: | | ||
npm install | ||
echo 'deploy with ${{ github.event.deployment.environment }}_sa' | ||
echo $PRODUCTION_SA > production-sa.json | ||
echo $DEVELOPMENT_SA > development-sa.json | ||
cp ${{ github.event.deployment.environment }}-sa.json service-account.json | ||
echo '' | ||
echo '' | ||
echo '' | ||
echo "${{ github.event.deployment.environment }}-sa.json" | ||
cat ${{ github.event.deployment.environment }}-sa.json | ||
GOOGLE_APPLICATION_CREDENTIALS=./service-account.json make deploy/${{ github.event.deployment.environment }} | ||
- name: 'deployment success' | ||
if: success() | ||
uses: 'deliverybot/deployment-status@master' | ||
with: | ||
state: 'success' | ||
token: '${{ github.token }}' | ||
|
||
- name: 'deployment failure' | ||
if: failure() | ||
uses: 'deliverybot/deployment-status@master' | ||
with: | ||
state: 'failure' | ||
token: '${{ github.token }}' |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.env | ||
/tmp | ||
/node_modules | ||
/lib |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"private": true, | ||
"version": "0.7.2", | ||
"workspaces": [ | ||
"packages/app", | ||
"packages/client", | ||
"packages/firebase", | ||
"packages/core", | ||
"packages/deploybot", | ||
"packages/slackbot", | ||
"packages/run" | ||
], | ||
"scripts": { | ||
"bump": "./bump.sh", | ||
"start": "node ./scripts/build.js --watch", | ||
"test": "node ./scripts/build.js --test", | ||
"server": "node ./scripts/server.js", | ||
"format": "prettier --write 'packages/*/src/**/*.{ts,js}'", | ||
"build": "node ./scripts/build.js", | ||
"push": "node ./scripts/build.js --publish" | ||
}, | ||
"prettier": { | ||
"trailingComma": "all" | ||
}, | ||
"devDependencies": { | ||
"prettier": "1.19.1", | ||
"smee-client": "^1.1.0", | ||
"standard-version": "7.1.0" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
const fs = require('fs'); | ||
const { spawn } = require('child_process'); | ||
|
||
const procs = []; | ||
|
||
function shutdown() { | ||
procs.forEach(proc => { | ||
proc.kill('SIGTERM'); | ||
}); | ||
} | ||
|
||
function run(pkg, cmd, onChange) { | ||
function pad(name, to) { | ||
let p = ""; | ||
for (let i = 0; i < to - name.length; i++) { | ||
p += " "; | ||
} | ||
return `${name}:${p}` | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
const proc = spawn('yarn', [cmd], { cwd: pkg === '.' ? '.' : `./packages/${pkg}` }); | ||
const name = pad(pkg, 10); | ||
procs.push(proc); | ||
proc.stdout.on('data', (data) => { | ||
data.toString().split("\n").forEach(line => { | ||
if (line.trim()) process.stdout.write(`${name} ${line}\n`); | ||
}); | ||
if (onChange) onChange(); | ||
}); | ||
proc.stderr.on('data', (data) => { | ||
data.toString().split("\n").forEach(line => { | ||
if (line.trim()) process.stdout.write(`${name} ${line}\n`); | ||
}); | ||
if (onChange) onChange(); | ||
}); | ||
proc.on("close", (code) => { | ||
if (code !== 0) { | ||
console.log(`${name} ${cmd} exited with code ${code}`); | ||
return reject(code); | ||
} | ||
return resolve(); | ||
}); | ||
}); | ||
} | ||
|
||
function debounce(func, wait) { | ||
let timeout; | ||
return function (...args) { | ||
clearTimeout(timeout); | ||
timeout = setTimeout(() => { | ||
func.apply(this, args); | ||
}, wait); | ||
}; | ||
} | ||
|
||
const restart = debounce(() => { | ||
console.log("--> restart"); | ||
fs.utimes("tmp/restart.txt", new Date(), new Date(), (err) => { | ||
if (err) console.error("Failed touch restart.txt", err); | ||
}); | ||
}, 1000); | ||
|
||
async function main() { | ||
try { | ||
fs.mkdirSync("./tmp"); | ||
} catch (err) { | ||
// Ignore. | ||
} | ||
try { | ||
fs.writeFileSync("./tmp/restart.txt", ""); | ||
} catch (err) { | ||
// Ignore. | ||
} | ||
|
||
const watch = process.argv[2] == '--watch'; | ||
const publish = process.argv[2] == '--publish'; | ||
const test = process.argv[2] == '--test'; | ||
|
||
if (watch) { | ||
await Promise.all([ | ||
run('.', 'server'), | ||
run('core', 'build:watch', restart), | ||
run('app', 'build:watch', restart), | ||
run('app', 'partials:watch', restart), | ||
run('client', 'build:watch', restart), | ||
run('run', 'build:watch', restart), | ||
run('run', 'bundle:watch', restart), | ||
]); | ||
} else if (test) { | ||
await Promise.all([ | ||
run('app', 'test'), | ||
]); | ||
} else { | ||
await Promise.all([ | ||
run('core', 'clean'), | ||
run('app', 'clean'), | ||
run('client', 'clean'), | ||
run('run', 'clean'), | ||
run('firebase', 'clean'), | ||
run('deploybot', 'clean'), | ||
run('slackbot', 'clean'), | ||
]); | ||
await run('core', 'build'); | ||
await Promise.all([ | ||
await run('deploybot', 'build'), | ||
await run('slackbot', 'build'), | ||
]); | ||
await Promise.all([ | ||
run('app', 'build'), | ||
run('app', 'partials'), | ||
run('client', 'build'), | ||
]); | ||
await run('run', 'build'); | ||
await run('run', 'bundle'); | ||
await run('firebase', 'build'); | ||
} | ||
|
||
if (publish) { | ||
console.log("\n\nPublishing...") | ||
await run('app', 'publish'); | ||
await run('client', 'publish'); | ||
await run('core', 'publish'); | ||
} | ||
|
||
console.log("done"); | ||
process.exit(0); | ||
} | ||
|
||
main().catch(() => { | ||
shutdown(); | ||
}); | ||
|
||
['SIGINT', 'SIGTERM', 'SIGQUIT'].forEach(sig => process.on(sig, () => { | ||
shutdown(); | ||
})); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const pkg = require("../package.json"); | ||
const fs = require("fs"); | ||
|
||
const version = pkg.version; | ||
|
||
pkg.workspaces.forEach(wrk => { | ||
const path = `${wrk}/package.json`; | ||
const wrkPkg = JSON.parse(fs.readFileSync(path).toString()); | ||
wrkPkg.version = version; | ||
Object.keys(wrkPkg.dependencies).forEach(dep => { | ||
if (dep.startsWith("@deliverybot")) { | ||
wrkPkg.dependencies[dep] = version; | ||
} | ||
}); | ||
fs.writeFileSync(path, JSON.stringify(wrkPkg, null, 2) + "\n"); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
./node_modules/.bin/standard-version --skip.commit $@ | ||
node ./scripts/bump-versions.js | ||
|
||
version=$(jq -r '.version' < ./package.json) | ||
|
||
git add . | ||
git commit -m "chore: release v${version}" | ||
git tag "v${version}" | ||
git push --follow-tags origin master |
Oops, something went wrong.