Skip to content

Commit 18f5d43

Browse files
authored
Merge pull request #14 from BunnyWay/changeset-release/main
🎉 Release
2 parents 51a2069 + 8aaf3a5 commit 18f5d43

4 files changed

Lines changed: 38 additions & 22 deletions

File tree

.changeset/mighty-wombats-kneel.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

deploy-script/.lib-action/index.js

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24962,11 +24962,18 @@ function run() {
2496224962
return __awaiter(this, void 0, void 0, function* () {
2496324963
try {
2496424964
// const githubToken = core.getInput('token', { required: true });
24965-
const scriptId = core.getInput('script_id', { required: true });
24966-
const deployKey = core.getInput('deploy_key', { required: true });
24967-
const base = core.getInput('base', { required: false });
24968-
const client = Bunny.createClient(base, deployKey);
24969-
const file_path = core.getInput('file', { required: true });
24965+
const scriptId = core.getInput("script_id", { required: true });
24966+
const deployKey = core.getInput("deploy_key", { required: false });
24967+
const base = core.getInput("base", { required: false });
24968+
let token;
24969+
if (deployKey == "") {
24970+
token = Bunny.newOIDCToken(yield core.getIDToken());
24971+
}
24972+
else {
24973+
token = Bunny.newDeployKey(deployKey);
24974+
}
24975+
const client = Bunny.createClient(base, token);
24976+
const file_path = core.getInput("file", { required: true });
2497024977
const fileContent = yield fs.readFile(file_path, { encoding: "utf-8" });
2497124978
yield Bunny.deployScript(client)(scriptId, fileContent);
2497224979
}
@@ -24995,18 +25002,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
2499525002
});
2499625003
};
2499725004
Object.defineProperty(exports, "__esModule", ({ value: true }));
24998-
exports.createClient = exports.deployScript = void 0;
25005+
exports.newOIDCToken = exports.newDeployKey = exports.createClient = exports.deployScript = void 0;
25006+
const newDeployKey = (token) => ({ _internal: "deploy", token });
25007+
exports.newDeployKey = newDeployKey;
25008+
const newOIDCToken = (token) => ({ _internal: "oidc", token });
25009+
exports.newOIDCToken = newOIDCToken;
2499925010
const createClient = (base, token) => { return ({ base, token }); };
2500025011
exports.createClient = createClient;
2500125012
const deployScript = (client) => (scriptId, code) => __awaiter(void 0, void 0, void 0, function* () {
25013+
const headers = {
25014+
"Accept": "application/json",
25015+
"Content-Type": "application/json",
25016+
};
25017+
switch (client.token._internal) {
25018+
case "deploy":
25019+
headers["DeploymentKey"] = client.token.token;
25020+
break;
25021+
case "oidc":
25022+
headers["GithubToken"] = client.token.token;
25023+
break;
25024+
}
2500225025
const endpoint_save = `${client.base}/compute/script/${scriptId}/code`;
2500325026
const response = yield fetch(endpoint_save, {
2500425027
method: "POST",
25005-
headers: {
25006-
"Accept": "application/json",
25007-
"Content-Type": "application/json",
25008-
"DeploymentKey": client.token,
25009-
},
25028+
headers,
2501025029
body: JSON.stringify({ Code: code }),
2501125030
});
2501225031
if (!response.ok) {
@@ -25017,11 +25036,7 @@ const deployScript = (client) => (scriptId, code) => __awaiter(void 0, void 0, v
2501725036
const endpoint_publish = `${client.base}/compute/script/${scriptId}/publish`;
2501825037
const responsePublish = yield fetch(endpoint_publish, {
2501925038
method: "POST",
25020-
headers: {
25021-
"Accept": "application/json",
25022-
"Content-Type": "application/json",
25023-
"DeploymentKey": client.token,
25024-
},
25039+
headers,
2502525040
});
2502625041
if (!responsePublish.ok) {
2502725042
console.error(`Failed to publish script: ${response.statusText}`);

deploy-script/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# deploy-script
22

3+
## 0.4.0
4+
5+
### Minor Changes
6+
7+
- d382bac: Add a OIDC Token
8+
39
## 0.3.0
410

511
### Minor Changes

deploy-script/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deploy-script",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"main": "lib/main.js",
55
"private": true,
66
"scripts": {

0 commit comments

Comments
 (0)