Skip to content

Commit

Permalink
Merge pull request #14 from BunnyWay/changeset-release/main
Browse files Browse the repository at this point in the history
🎉 Release
  • Loading branch information
antho-bunny authored Sep 4, 2024
2 parents 51a2069 + 8aaf3a5 commit 18f5d43
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
5 changes: 0 additions & 5 deletions .changeset/mighty-wombats-kneel.md

This file was deleted.

47 changes: 31 additions & 16 deletions deploy-script/.lib-action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24962,11 +24962,18 @@ function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
// const githubToken = core.getInput('token', { required: true });
const scriptId = core.getInput('script_id', { required: true });
const deployKey = core.getInput('deploy_key', { required: true });
const base = core.getInput('base', { required: false });
const client = Bunny.createClient(base, deployKey);
const file_path = core.getInput('file', { required: true });
const scriptId = core.getInput("script_id", { required: true });
const deployKey = core.getInput("deploy_key", { required: false });
const base = core.getInput("base", { required: false });
let token;
if (deployKey == "") {
token = Bunny.newOIDCToken(yield core.getIDToken());
}
else {
token = Bunny.newDeployKey(deployKey);
}
const client = Bunny.createClient(base, token);
const file_path = core.getInput("file", { required: true });
const fileContent = yield fs.readFile(file_path, { encoding: "utf-8" });
yield Bunny.deployScript(client)(scriptId, fileContent);
}
Expand Down Expand Up @@ -24995,18 +25002,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.createClient = exports.deployScript = void 0;
exports.newOIDCToken = exports.newDeployKey = exports.createClient = exports.deployScript = void 0;
const newDeployKey = (token) => ({ _internal: "deploy", token });
exports.newDeployKey = newDeployKey;
const newOIDCToken = (token) => ({ _internal: "oidc", token });
exports.newOIDCToken = newOIDCToken;
const createClient = (base, token) => { return ({ base, token }); };
exports.createClient = createClient;
const deployScript = (client) => (scriptId, code) => __awaiter(void 0, void 0, void 0, function* () {
const headers = {
"Accept": "application/json",
"Content-Type": "application/json",
};
switch (client.token._internal) {
case "deploy":
headers["DeploymentKey"] = client.token.token;
break;
case "oidc":
headers["GithubToken"] = client.token.token;
break;
}
const endpoint_save = `${client.base}/compute/script/${scriptId}/code`;
const response = yield fetch(endpoint_save, {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"DeploymentKey": client.token,
},
headers,
body: JSON.stringify({ Code: code }),
});
if (!response.ok) {
Expand All @@ -25017,11 +25036,7 @@ const deployScript = (client) => (scriptId, code) => __awaiter(void 0, void 0, v
const endpoint_publish = `${client.base}/compute/script/${scriptId}/publish`;
const responsePublish = yield fetch(endpoint_publish, {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"DeploymentKey": client.token,
},
headers,
});
if (!responsePublish.ok) {
console.error(`Failed to publish script: ${response.statusText}`);
Expand Down
6 changes: 6 additions & 0 deletions deploy-script/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# deploy-script

## 0.4.0

### Minor Changes

- d382bac: Add a OIDC Token

## 0.3.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion deploy-script/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deploy-script",
"version": "0.3.0",
"version": "0.4.0",
"main": "lib/main.js",
"private": true,
"scripts": {
Expand Down

0 comments on commit 18f5d43

Please sign in to comment.