summaryrefslogtreecommitdiffstats
path: root/upload_to_mega.js
blob: c0abd5ed51be764f4e2094028a41aadcbb6b31f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var util = require('util');
var exec = require('child_process').exec;
var sanitize = require("sanitize-filename");

var email = process.env.MEGA_EMAIL;
var password = process.env.MEGA_PASSWORD;
var sourceFileName = 'build.7z';
var dstFileName = process.env.APPVEYOR_REPO_COMMIT.substring(0, 8) + " - " + 
                process.env.APPVEYOR_REPO_COMMIT_MESSAGE.substring(0, 100) + ".7z";
dstFileName = sanitize(dstFileName);

var cmd = util.format('megaput ../%s --path \"/Root/Citra/Windows/%s\" --username=%s --password=%s --no-progress',
                        sourceFileName,
                        dstFileName,
                        email,
                        password);

// only upload build on master branch, and not on other branches or PRs
if (process.env.APPVEYOR_REPO_BRANCH == "master") {
    console.log("Uploading file " + dstFileName + " to Mega...");
    exec(cmd, function(error, stdout, stderr) {
        console.log('stdout: ' + stdout);
        console.log('stderr: ' + stderr);
        if (error !== null) {
            console.log('exec error: ' + error);
        }
    });            
}