Skip to content

Commit

Permalink
Merge pull request #12 from SkynetLabs/update-nodejs-add-jwt
Browse files Browse the repository at this point in the history
remove skynet-js dep, add cookie option
  • Loading branch information
kwypchlo authored Nov 8, 2021
2 parents 158dc2d + d8d6681 commit 1d544fb
Show file tree
Hide file tree
Showing 109 changed files with 10,500 additions and 1,922 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#VSCode settings
.vscode
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Define a path to a file that will replace the default 404 Not Found error page,

### `registry-seed`

**USE GITHUB SECRET - DO NOT COMMIT THIS IN PLAIN TEXT**

You can provide a seed (keep it secret, keep it safe) and this action will set corresponding skynet registry entry value to the deployed resolver skylink.

Public link to the registry entry will be printed in the action log.
Expand All @@ -48,6 +50,13 @@ Default value: `https://siasky.net`

You can override default skynet portal url with any compatible community portal or self hosted one.

### `skynet-jwt`

**USE GITHUB SECRET - DO NOT COMMIT THIS IN PLAIN TEXT**

Portal account JWT used for associating uploads with a specific account. Also used to allow uploads larger than 1GB.
[Obtaining your JWT.](https://docs.siasky.net/developer-guides/server-hosted-skynet-usage#obtaining-your-jwt)

## Outputs

### `skylink`
Expand Down Expand Up @@ -78,7 +87,6 @@ Example: `https://040f11qosugpdb7kmq5hobu3sfmr4fulr06tcspmrjtdgvg3oc6m630.siasky

```yaml
uses: SkynetLabs/deploy-to-skynet-action@v2

with:
upload-dir: public
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -112,7 +120,6 @@ jobs:

- name: Deploy to Skynet
uses: SkynetLabs/deploy-to-skynet-action@v2

with:
upload-dir: public
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ inputs:
description: "Skynet portal api url"
required: true
default: "https://siasky.net"
skynet-jwt:
description: "Portal account JWT used for associating uploads with a specific account. Also used to allow uploads larger than 1GB."
required: false
outputs:
skylink:
description: "Uploaded resource skylink"
Expand Down
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const core = require("@actions/core");
const github = require("@actions/github");
const { SkynetClient: NodeSkynetClient } = require("@skynetlabs/skynet-nodejs");
const { genKeyPairFromSeed, SkynetClient } = require("skynet-js");
const {
SkynetClient,
genKeyPairFromSeed,
} = require("@skynetlabs/skynet-nodejs");

function outputAxiosErrorMessage(error) {
if (error.response) {
Expand Down Expand Up @@ -30,15 +32,19 @@ function prepareUploadOptions() {
options.errorPages = { 404: core.getInput("not-found-page") };
}

if (core.getInput("skynet-jwt")) {
// transform skynet-jwt into a cookie accepted format
options.customCookie = `skynet-jwt=${core.getInput("skynet-jwt")}`;
}

return options;
}

(async () => {
try {
// upload to skynet
const nodeClient = new NodeSkynetClient(core.getInput("portal-url"));
const skynetClient = new SkynetClient(core.getInput("portal-url"));
const skylink = await nodeClient.uploadDirectory(
const skylink = await skynetClient.uploadDirectory(
core.getInput("upload-dir"),
prepareUploadOptions()
);
Expand Down
66 changes: 43 additions & 23 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@skynetlabs/skynet-nodejs/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions node_modules/@skynetlabs/skynet-nodejs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions node_modules/@skynetlabs/skynet-nodejs/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion node_modules/@skynetlabs/skynet-nodejs/scripts/upload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions node_modules/@skynetlabs/skynet-nodejs/src/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions node_modules/@skynetlabs/skynet-nodejs/src/upload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1d544fb

Please sign in to comment.