Skip to content

Instantly share code, notes, and snippets.

@zhigang1992 zhigang1992/deploy.js Secret
Created Mar 30, 2019

Embed
What would you like to do?
Deploy to remote
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
You can’t perform that action at this time.