Skip to content

Commit

Permalink
chore: auto-update gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
justmoon committed May 26, 2016
1 parent a4089a4 commit e6d68c2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
apidoc-out/
/node_modules/
/web/
/apidoc-out/
coverage/
*.cluster
/npm-debug.log
Expand Down
13 changes: 9 additions & 4 deletions scripts/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,28 @@ uploadCoverage() {
fi
}

npmPublish() {
publishNpm() {
# Push NPM package if not yet published
mv npmrc-env .npmrc
if [ -z "$(npm info $(npm ls --depth=-1 2>/dev/null | head -1 | cut -f 1 -d " ") 2>/dev/null)" ]; then
npm publish
fi
}

dockerPush() {
pushDocker() {
# Push Docker image tagged latest and tagged with commit descriptor
sed "s/<AUTH>/${DOCKER_TOKEN}/" < "dockercfg-template" > ~/.dockercfg
docker tag interledger/five-bells-ledger:latest interledger/five-bells-ledger:"$(git describe)"
docker push interledger/five-bells-ledger:latest
docker push interledger/five-bells-ledger:"$(git describe)"
}

updateWebsite() {
node scripts/publish_web.js
}

# ST: Coverage reporting is broken - disable for now
# uploadCoverage
npmPublish
dockerPush
publishNpm
pushDocker
updateWebsite
36 changes: 36 additions & 0 deletions scripts/publish_web.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env node

const path = require('path')
const exec = require('child_process').execSync

let cwd = path.resolve(__dirname, '..')

// Get current web branch
console.log('\n# Cloning web branch')
exec('rm -rf web', { cwd })
exec('git clone git@github.com:interledger/five-bells-ledger.git --branch gh-pages --single-branch web', { cwd })

// Update apidoc
console.log('\n# Updating API docs')
exec('npm run apidoc', { cwd })
exec('mkdir -p web/apidoc', { cwd })
exec('cp -r apidoc-out/* web/apidoc/', { cwd })

// Update apidoc-template
console.log('\n# Updating API doc template')
exec('wget https://github.com/interledger/apidoc-template/archive/master.tar.gz -O - | tar xzf - --strip 1 -C web/apidoc', { cwd })

// Push changes
console.log('\n# Pushing web branch')
cwd = path.resolve(cwd, 'web')
exec('cd web')
exec('git add --all', { cwd })

const status = exec('git status --porcelain', { cwd }).toString('utf8')
if (!status.length) {
console.log('no changes')
} else {
console.log(status)
exec('git commit -m \'chore: update gh-pages\'', { cwd })
exec('git push', { cwd })
}

0 comments on commit e6d68c2

Please sign in to comment.