Skip to content

Commit c074bfa

Browse files
authored
Merge pull request #9 from BunnyWay/feat-prepare-action
Prepare action
2 parents edadcc0 + 3861ee5 commit c074bfa

7 files changed

Lines changed: 51 additions & 12 deletions

File tree

.changeset/fast-singers-mix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"deploy-script": minor
3+
---
4+
5+
Use DeployKey instead of AccessKey

.github/workflows/changeset.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
1010
jobs:
1111
release:
1212
permissions:
13-
contents: write # to create release (changesets/action)
14-
issues: write # to post issue comments (changesets/action)
15-
pull-requests: write # to create pull request (changesets/action)
13+
contents: write
14+
issues: write
15+
pull-requests: write
1616

1717
if: github.repository == 'BunnyWay/actions'
1818

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Continous integration
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
8+
jobs:
9+
checkout:
10+
runs-on: ubuntu-latest
11+
12+
name: 'Install, lint and test'
13+
14+
steps:
15+
- name: 'Checkout'
16+
uses: actions/checkout@v4
17+
18+
- name: 'Setup Javascript'
19+
uses: ./.github/actions/setup-project
20+
21+
- name: 'Lint'
22+
run: pnpm run -r lint
23+
24+
- name: 'Test'
25+
run: pnpm run -r test

deploy-script/action.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,19 @@ inputs:
1111
description: The ScriptID associated to your Pullzone.
1212
required: true
1313

14-
access_key:
15-
description: The associated AccessKey or DeployKey from Bunny.
14+
deploy_key:
15+
description: The associated DeployKey for Bunny.
1616
required: true
1717

1818
file:
1919
description: The file path for the script.
2020
required: true
2121

22+
base:
23+
description: The API endpoint - Only used for debug
24+
required: false
25+
default: 'https://api.bunny.net'
26+
2227
runs:
2328
using: 'node20'
2429
main: '.lib-action/index.js'

deploy-script/src/action.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ describe('action', () => {
2323
switch (input) {
2424
case 'script_id':
2525
return "12345";
26-
case 'access_key':
26+
case 'deploy_key':
2727
return "private_token";
28+
case 'base':
29+
return "base_url";
2830
case 'file':
2931
return "/path/to/file";
3032
default:
@@ -47,11 +49,12 @@ describe('action', () => {
4749

4850
// Verify that inputs were fetched
4951
expect(core.getInput).toHaveBeenCalledWith('script_id', { required: true });
50-
expect(core.getInput).toHaveBeenCalledWith('access_key', { required: true });
52+
expect(core.getInput).toHaveBeenCalledWith('deploy_key', { required: true });
5153
expect(core.getInput).toHaveBeenCalledWith('file', { required: true });
54+
expect(core.getInput).toHaveBeenCalledWith('base', { required: false });
5255

5356
// Verify that the client was created
54-
expect(Bunny.createClient).toHaveBeenCalledWith("https://api.bunny.net", "private_token");
57+
expect(Bunny.createClient).toHaveBeenCalledWith("base_url", "private_token");
5558

5659
// Verify that the file was read
5760
expect(fs.readFile).toHaveBeenCalledWith("/path/to/file", { encoding: "utf-8" });

deploy-script/src/action.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ export async function run() {
66
try {
77
// const githubToken = core.getInput('token', { required: true });
88
const scriptId = core.getInput('script_id', { required: true });
9-
const accessKey = core.getInput('access_key', { required: true });
9+
const deployKey = core.getInput('deploy_key', { required: true });
10+
const base = core.getInput('base', { required: false });
1011

11-
const client = Bunny.createClient("https://api.bunny.net", accessKey);
12+
const client = Bunny.createClient(base, deployKey);
1213

1314
const file_path = core.getInput('file', { required: true });
1415

deploy-script/src/bunny.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const deployScript = (client: BunnyClient) => async (scriptId: string, code: str
1212
headers: {
1313
"Accept": "application/json",
1414
"Content-Type": "application/json",
15-
"Accesskey": client.token,
15+
"DeploymentKey": client.token,
1616
},
1717
body: JSON.stringify({ Code: code }),
1818
});
@@ -30,7 +30,7 @@ const deployScript = (client: BunnyClient) => async (scriptId: string, code: str
3030
headers: {
3131
"Accept": "application/json",
3232
"Content-Type": "application/json",
33-
"Accesskey": client.token,
33+
"DeploymentKey": client.token,
3434
},
3535
});
3636

0 commit comments

Comments
 (0)