Fixed #5 - Added input for providing the text of the service account json to authorize the action

This commit is contained in:
Drew Heavner
2020-02-12 10:55:53 -05:00
parent ec56d49b16
commit 290e6a13bf
4 changed files with 55 additions and 9 deletions

View File

@@ -26,13 +26,32 @@ const auth = new google.auth.GoogleAuth({
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const serviceAccountJson = core.getInput('serviceAccountJson', { required: true });
const serviceAccountJson = core.getInput('serviceAccountJson', { required: false });
const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false });
const packageName = core.getInput('packageName', { required: true });
const releaseFile = core.getInput('releaseFile', { required: true });
const track = core.getInput('track', { required: true });
const userFraction = core.getInput('userFraction', { required: false });
const whatsNewDir = core.getInput('whatsNewDirectory', { required: false });
const mappingFile = core.getInput('mappingFile', { required: false });
if (!serviceAccountJson && !serviceAccountJsonRaw) {
console.log("No service account json key provided!");
core.setFailed("You must provide one of 'serviceAccountJson' or 'serviceAccountJsonPlainText' to use this action");
}
// If the user has provided the raw plain text via secrets, or w/e, then write to file and
// set appropriate env variable for the auth
if (serviceAccountJsonRaw) {
const serviceAccountFile = "./serviceAccountJson.json";
fs.writeFileSync(serviceAccountFile, serviceAccountJsonRaw, {
encoding: 'utf8'
});
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountFile);
}
if (serviceAccountJson) {
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
}
// verify inputs
let userFractionFloat = parseFloat(userFraction);
if (!isNaN(userFractionFloat)) {
@@ -57,8 +76,6 @@ function run() {
core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`);
return;
}
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
const authClient = yield auth.getClient();
yield edits_1.uploadRelease({
auth: authClient,