generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
also upgrades various dependencies
- Loading branch information
Showing
742 changed files
with
601,859 additions
and
752,258 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.collectDeploymentContext = void 0; | ||
const core_1 = require("@actions/core"); | ||
const github_1 = require("@actions/github"); | ||
function collectDeploymentContext() { | ||
const { ref, sha } = github_1.context; | ||
const customRepository = core_1.getInput("repository", { required: false }); | ||
const [owner, repo] = customRepository | ||
? customRepository.split("/") | ||
: [github_1.context.repo.owner, github_1.context.repo.repo]; | ||
if (!owner || !repo) { | ||
throw new Error(`invalid target repository: ${owner}/${repo}`); | ||
} | ||
const github = github_1.getOctokit(core_1.getInput("token", { required: true }), { | ||
previews: ["ant-man-preview", "flash-preview"], | ||
}); | ||
return { | ||
ref, | ||
sha, | ||
owner, | ||
repo, | ||
github, | ||
coreArgs: { | ||
autoInactive: core_1.getInput("auto_inactive") !== "false", | ||
logsURL: core_1.getInput("logs") || | ||
`https://github.com/${owner}/${repo}/commit/${sha}/checks`, | ||
description: core_1.getInput("desc"), | ||
logArgs: core_1.getInput("log_args") === "true", | ||
}, | ||
}; | ||
} | ||
exports.collectDeploymentContext = collectDeploymentContext; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function deactivateEnvironment({ github: client, owner, repo }, environment) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const deployments = yield client.rest.repos.listDeployments({ | ||
owner, | ||
repo, | ||
environment, | ||
}); | ||
const existing = deployments.data.length; | ||
if (existing < 1) { | ||
console.log(`found no existing deployments for env ${environment}`); | ||
return; | ||
} | ||
const deadState = "inactive"; | ||
console.log(`found ${existing} existing deployments for env ${environment} - marking as ${deadState}`); | ||
for (let i = 0; i < existing; i++) { | ||
const deployment = deployments.data[i]; | ||
console.log(`setting deployment '${environment}.${deployment.id}' (${deployment.sha}) state to "${deadState}"`); | ||
yield client.rest.repos.createDeploymentStatus({ | ||
owner, | ||
repo, | ||
deployment_id: deployment.id, | ||
state: deadState, | ||
}); | ||
} | ||
console.log(`${existing} deployments updated`); | ||
}); | ||
} | ||
exports.default = deactivateEnvironment; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.run = exports.Step = void 0; | ||
const core_1 = require("@actions/core"); | ||
const deactivate_1 = __importDefault(require("../lib/deactivate")); | ||
var Step; | ||
(function (Step) { | ||
Step["Start"] = "start"; | ||
Step["Finish"] = "finish"; | ||
Step["DeactivateEnv"] = "deactivate-env"; | ||
})(Step = exports.Step || (exports.Step = {})); | ||
function run(step, context) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { github } = context; | ||
try { | ||
switch (step) { | ||
case Step.Start: | ||
{ | ||
const args = Object.assign(Object.assign({}, context.coreArgs), { environment: core_1.getInput("env", { required: true }), noOverride: core_1.getInput("no_override") !== "false", transient: core_1.getInput("transient") === "true", gitRef: core_1.getInput("ref") || context.ref }); | ||
if (args.logArgs) { | ||
console.log(`'${step}' arguments`, args); | ||
} | ||
let deploymentID = core_1.getInput("deployment_id"); | ||
console.log(`initializing deployment ${deploymentID} for ${args.environment} @ ${args.gitRef}`); | ||
// mark existing deployments of this environment as inactive | ||
if (!args.noOverride) { | ||
yield deactivate_1.default(context, args.environment); | ||
} | ||
if (!deploymentID) { | ||
const deployment = yield github.rest.repos.createDeployment({ | ||
owner: context.owner, | ||
repo: context.repo, | ||
ref: args.gitRef, | ||
required_contexts: [], | ||
environment: args.environment, | ||
auto_merge: false, | ||
transient_environment: args.transient, | ||
}); | ||
// TODO: why does typecheck fail on `data.id`? | ||
deploymentID = deployment.data.id.toString(); | ||
} | ||
console.log(`created deployment ${deploymentID} for ${args.environment} @ ${args.gitRef}`); | ||
core_1.setOutput("deployment_id", deploymentID); | ||
core_1.setOutput("env", args.environment); | ||
yield github.rest.repos.createDeploymentStatus({ | ||
owner: context.owner, | ||
repo: context.repo, | ||
deployment_id: parseInt(deploymentID, 10), | ||
state: "in_progress", | ||
auto_inactive: args.autoInactive, | ||
log_url: args.logsURL, | ||
description: args.description, | ||
}); | ||
console.log('deployment status set to "in_progress"'); | ||
} | ||
break; | ||
case Step.Finish: | ||
{ | ||
const args = Object.assign(Object.assign({}, context.coreArgs), { deploymentID: core_1.getInput("deployment_id", { required: true }), envURL: core_1.getInput("env_url", { required: false }), status: core_1.getInput("status", { required: true }).toLowerCase() }); | ||
if (args.logArgs) { | ||
console.log(`'${step}' arguments`, args); | ||
} | ||
if (args.status !== "success" && | ||
args.status !== "failure" && | ||
args.status !== "cancelled") { | ||
core_1.error(`unexpected status ${args.status}`); | ||
return; | ||
} | ||
console.log(`finishing deployment for ${args.deploymentID} with status ${args.status}`); | ||
const newStatus = args.status === "cancelled" ? "inactive" : args.status; | ||
yield github.rest.repos.createDeploymentStatus({ | ||
owner: context.owner, | ||
repo: context.repo, | ||
deployment_id: parseInt(args.deploymentID, 10), | ||
state: newStatus, | ||
auto_inactive: args.autoInactive, | ||
description: args.description, | ||
// only set environment_url if deployment worked | ||
environment_url: newStatus === "success" ? args.envURL : "", | ||
// set log_url to action by default | ||
log_url: args.logsURL, | ||
}); | ||
console.log(`${args.deploymentID} status set to ${newStatus}`); | ||
} | ||
break; | ||
case Step.DeactivateEnv: | ||
{ | ||
const args = Object.assign(Object.assign({}, context.coreArgs), { environment: core_1.getInput("env", { required: true }) }); | ||
if (args.logArgs) { | ||
console.log(`'${step}' arguments`, args); | ||
} | ||
yield deactivate_1.default(context, args.environment); | ||
} | ||
break; | ||
default: | ||
core_1.setFailed(`unknown step type ${step}`); | ||
} | ||
} | ||
catch (error) { | ||
core_1.setFailed(`unexpected error encountered: ${error.message}`); | ||
} | ||
}); | ||
} | ||
exports.run = run; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.