Skip to content

Commit 693ee9e

Browse files
committed
Run build
1 parent a9697fe commit 693ee9e

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

action/dist/index.js

+40-38
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,10 @@ var mkdir = util_1.promisify(fs.mkdir);
570570
var mkdtemp = util_1.promisify(fs.mkdtemp);
571571
// Environment Variables
572572
/**
573-
* The URL of the repository to push to, one-of:
573+
* The URL of the repository to push to, either:
574574
*
575575
* * an ssh URL to a repository
576+
* * the string `"self"`
576577
*/
577578
var REPO = process.env.REPO;
578579
/**
@@ -598,7 +599,6 @@ var GITHUB_TOKEN = process.env.GITHUB_TOKEN;
598599
// Implicit environment variables passed by GitHub
599600
var GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY;
600601
var GITHUB_EVENT_PATH = process.env.GITHUB_EVENT_PATH;
601-
var GITHUB_SHA = process.env.GITHUB_SHA;
602602
var GITHUB_ACTOR = process.env.GITHUB_ACTOR;
603603
// Error messages
604604
var KNOWN_HOSTS_WARNING = "\n##[warning] KNOWN_HOSTS_FILE not set\nThis will probably mean that host verification will fail later on\n";
@@ -681,7 +681,7 @@ var writeToProcess = function (command, args, opts) { return new Promise(functio
681681
});
682682
}); };
683683
(function () { return __awaiter(void 0, void 0, void 0, function () {
684-
var TMP_PATH, REPO_TEMP, SSH_AUTH_SOCK, event, _a, _b, name, email, env, known_hosts, sshAgentMatch, _c, _d, branchCheck, folder, sha, push;
684+
var TMP_PATH, REPO_TEMP, SSH_AUTH_SOCK, event, _a, _b, name, email, sha, env, known_hosts, sshAgentMatch, _c, _d, branchCheck, folder, push;
685685
return __generator(this, function (_e) {
686686
switch (_e.label) {
687687
case 0: return [4 /*yield*/, mkdtemp(path.join(os_1.tmpdir(), 'git-publish-subdir-action-'))];
@@ -705,31 +705,34 @@ var writeToProcess = function (command, args, opts) { return new Promise(functio
705705
return [4 /*yield*/, exec("git config --global user.email \"" + email + "\"")];
706706
case 4:
707707
_e.sent();
708+
return [4 /*yield*/, exec("git rev-parse HEAD")];
709+
case 5:
710+
sha = (_e.sent()).stdout.trim().substr(0, 7);
708711
env = Object.assign({}, process.env, {
709712
SSH_AUTH_SOCK: SSH_AUTH_SOCK
710713
});
711-
if (!(config.mode === 'ssh')) return [3 /*break*/, 11];
714+
if (!(config.mode === 'ssh')) return [3 /*break*/, 12];
712715
known_hosts = config.knownHostsFile;
713716
// Use well-known known_hosts for certain domains
714717
if (!known_hosts && config.parsedUrl.resource === 'github.com') {
715718
known_hosts = KNOWN_HOSTS_GITHUB;
716719
}
717-
if (!!known_hosts) return [3 /*break*/, 5];
720+
if (!!known_hosts) return [3 /*break*/, 6];
718721
console.warn(KNOWN_HOSTS_WARNING);
719-
return [3 /*break*/, 8];
720-
case 5: return [4 /*yield*/, mkdir(SSH_FOLDER, { recursive: true })];
721-
case 6:
722-
_e.sent();
723-
return [4 /*yield*/, copyFile(known_hosts, KNOWN_HOSTS_TARGET)];
722+
return [3 /*break*/, 9];
723+
case 6: return [4 /*yield*/, mkdir(SSH_FOLDER, { recursive: true })];
724724
case 7:
725725
_e.sent();
726-
_e.label = 8;
726+
return [4 /*yield*/, copyFile(known_hosts, KNOWN_HOSTS_TARGET)];
727727
case 8:
728+
_e.sent();
729+
_e.label = 9;
730+
case 9:
728731
// Setup ssh-agent with private key
729732
console.log("Setting up ssh-agent on " + SSH_AUTH_SOCK);
730733
_d = (_c = SSH_AGENT_PID_EXTRACT).exec;
731734
return [4 /*yield*/, exec("ssh-agent -a " + SSH_AUTH_SOCK, { env: env })];
732-
case 9:
735+
case 10:
733736
sshAgentMatch = _d.apply(_c, [(_e.sent()).stdout]);
734737
if (!sshAgentMatch)
735738
throw new Error('Unexpected output from ssh-agent');
@@ -745,11 +748,11 @@ var writeToProcess = function (command, args, opts) { return new Promise(functio
745748
}
746749
throw err;
747750
})];
748-
case 10:
751+
case 11:
749752
_e.sent();
750753
console.log("Private key added");
751-
_e.label = 11;
752-
case 11:
754+
_e.label = 12;
755+
case 12:
753756
// Clone the target repo
754757
return [4 /*yield*/, exec("git clone \"" + config.repo + "\" \"" + REPO_TEMP + "\"", {
755758
env: env
@@ -765,7 +768,7 @@ var writeToProcess = function (command, args, opts) { return new Promise(functio
765768
}
766769
throw err;
767770
})];
768-
case 12:
771+
case 13:
769772
// Clone the target repo
770773
_e.sent();
771774
// Fetch branch if it exists
@@ -776,72 +779,71 @@ var writeToProcess = function (command, args, opts) { return new Promise(functio
776779
console.error(err);
777780
}
778781
})];
779-
case 13:
782+
case 14:
780783
// Fetch branch if it exists
781784
_e.sent();
782785
// Check if branch already exists
783786
console.log("##[info] Checking if branch " + config.branch + " exists already");
784787
return [4 /*yield*/, exec("git branch --list \"" + config.branch + "\"", { env: env, cwd: REPO_TEMP })];
785-
case 14:
788+
case 15:
786789
branchCheck = _e.sent();
787-
if (!(branchCheck.stdout.trim() === '')) return [3 /*break*/, 21];
790+
if (!(branchCheck.stdout.trim() === '')) return [3 /*break*/, 22];
788791
// Branch does not exist yet, let's create an initial commit
789792
console.log("##[info] " + config.branch + " does not exist, creating initial commit");
790793
return [4 /*yield*/, exec("git checkout --orphan \"" + config.branch + "\"", { env: env, cwd: REPO_TEMP })];
791-
case 15:
792-
_e.sent();
793-
return [4 /*yield*/, exec("git rm -rf .", { env: env, cwd: REPO_TEMP }).catch(function (err) { })];
794794
case 16:
795795
_e.sent();
796-
return [4 /*yield*/, exec("touch README.md", { env: env, cwd: REPO_TEMP })];
796+
return [4 /*yield*/, exec("git rm -rf .", { env: env, cwd: REPO_TEMP }).catch(function (err) { })];
797797
case 17:
798798
_e.sent();
799-
return [4 /*yield*/, exec("git add README.md", { env: env, cwd: REPO_TEMP })];
799+
return [4 /*yield*/, exec("touch README.md", { env: env, cwd: REPO_TEMP })];
800800
case 18:
801801
_e.sent();
802-
return [4 /*yield*/, exec("git commit -m \"Initial " + config.branch + " commit\"", { env: env, cwd: REPO_TEMP })];
802+
return [4 /*yield*/, exec("git add README.md", { env: env, cwd: REPO_TEMP })];
803803
case 19:
804804
_e.sent();
805-
return [4 /*yield*/, exec("git push \"" + config.repo + "\" \"" + config.branch + "\"", { env: env, cwd: REPO_TEMP })];
805+
return [4 /*yield*/, exec("git commit -m \"Initial " + config.branch + " commit\"", { env: env, cwd: REPO_TEMP })];
806806
case 20:
807807
_e.sent();
808-
_e.label = 21;
808+
return [4 /*yield*/, exec("git push \"" + config.repo + "\" \"" + config.branch + "\"", { env: env, cwd: REPO_TEMP })];
809809
case 21:
810+
_e.sent();
811+
_e.label = 22;
812+
case 22:
810813
// Update contents of branch
811814
console.log("##[info] Updating branch " + config.branch);
812815
return [4 /*yield*/, exec("git checkout \"" + config.branch + "\"", { env: env, cwd: REPO_TEMP })];
813-
case 22:
816+
case 23:
814817
_e.sent();
815818
return [4 /*yield*/, exec("git rm -rf .", { env: env, cwd: REPO_TEMP }).catch(function (err) { })];
816-
case 23:
819+
case 24:
817820
_e.sent();
818821
folder = path.resolve(process.cwd(), config.folder);
819822
console.log("##[info] Copying all files from " + folder);
820823
// TODO: replace this copy with a node implementation
821824
return [4 /*yield*/, exec("cp -r " + folder + "/* ./", { env: env, cwd: REPO_TEMP })];
822-
case 24:
825+
case 25:
823826
// TODO: replace this copy with a node implementation
824827
_e.sent();
825828
return [4 /*yield*/, exec("git add -A .", { env: env, cwd: REPO_TEMP })];
826-
case 25:
829+
case 26:
827830
_e.sent();
828-
sha = GITHUB_SHA ? GITHUB_SHA.substr(0, 7) : 'unknown';
829831
return [4 /*yield*/, exec("git commit --allow-empty -m \"Update " + config.branch + " to output generated at " + sha + "\"", { env: env, cwd: REPO_TEMP })];
830-
case 26:
832+
case 27:
831833
_e.sent();
832834
console.log("##[info] Pushing");
833835
return [4 /*yield*/, exec("git push origin \"" + config.branch + "\"", { env: env, cwd: REPO_TEMP })];
834-
case 27:
836+
case 28:
835837
push = _e.sent();
836838
console.log(push.stdout);
837839
console.log("##[info] Deployment Successful");
838-
if (!(config.mode === 'ssh')) return [3 /*break*/, 29];
840+
if (!(config.mode === 'ssh')) return [3 /*break*/, 30];
839841
console.log("##[info] Killing ssh-agent");
840842
return [4 /*yield*/, exec("ssh-agent -k", { env: env })];
841-
case 28:
843+
case 29:
842844
_e.sent();
843-
_e.label = 29;
844-
case 29: return [2 /*return*/];
845+
_e.label = 30;
846+
case 30: return [2 /*return*/];
845847
}
846848
});
847849
}); })().catch(function (err) {

0 commit comments

Comments
 (0)