-
-
Save zhigang1992/d5c4d61b692ba8511ea6f52d54ce79c5 to your computer and use it in GitHub Desktop.
Deploy to remote
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 process = require('process'); | |
const fs = require('fs'); | |
const exec = require('ssh-exec'); | |
const buildCommand = release => ` | |
cd Projects/Project | |
git reset --hard HEAD | |
git clean -fd | |
git fetch | |
git fetch --prune --prune-tags | |
git checkout ${release.tag_name} | |
yarn install | |
FIREBASE_TOKEN=${process.env.FIREBASE_TOKEN} yarn use:${release.prerelease ? 'staging' : 'prod'} | |
cd app | |
security unlock-keychain -p ${process.env.MAC_PASSWORD} login.keychain | |
gem install bundler | |
bundle install | |
bundle exec pod install --repo-update | |
bundle exec fastlane beta tag:${tag_name} changelog:${JSON.stringify(release.body)} | |
`; | |
const run = release => { | |
exec( | |
buildCommand(release), | |
{ | |
user: process.env.MAC_USERNAME, | |
host: process.env.MAC_HOST, | |
password: process.env.MAC_PASSWORD, | |
port: process.env.MAC_PORT | |
}, | |
(err, stdout, stderr) => { | |
if (err) { | |
console.log(stderr); | |
console.log(err.message); | |
process.exit(1); | |
} | |
} | |
).pipe(process.stdout); | |
}; | |
const event = JSON.parse( | |
fs.readFileSync(process.env.GITHUB_EVENT_PATH, { | |
encoding: 'utf-8' | |
}) | |
); | |
const { body, name, tag_name, prerelease } = event.release; | |
run({ body, name, tag_name, prerelease }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment