Skip to content

Commit

Permalink
Merge pull request #7 from SkynetLabs/advanced-directory-upload-options
Browse files Browse the repository at this point in the history
support for try-files and not-found-page
  • Loading branch information
dghelm committed Sep 28, 2021
2 parents 5847c3c + 15aed71 commit 158dc2d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 17 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ This action requires the upload directory to be already available so you will ne

Find out more about github token from [documentation](https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow).

### `try-files`

Default value: `index.html`

Define a list of space separated files that portal should try to serve in if uri points to a directory, ie `index.html /index.html`.

### `not-found-page`

Define a path to a file that will replace the default 404 Not Found error page, ie `404.html`.

### `registry-seed`

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.
Expand Down
39 changes: 23 additions & 16 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
name: 'Skynet Deploy'
description: 'Deploy your static webapp to Skynet'
name: "Skynet Deploy"
description: "Deploy your static webapp to Skynet"
branding:
icon: 'cloud'
color: 'green'
icon: "cloud"
color: "green"
inputs:
upload-dir:
description: 'Directory to upload'
description: "Directory to upload"
required: true
github-token:
description: 'Github token used for including the skylink url in pull request'
description: "Github token used for including the skylink url in pull request"
required: true
try-files:
description: "Define a list of space separated files that portal should try to serve in if uri points to a directory"
required: false
default: "index.html"
not-found-page:
description: "Define a path to a file that will replace the default 404 Not Found error page"
required: false
registry-seed:
description: 'Seed that generates registry private key (optional, only if you want to update the registry entry with skylink)'
description: "Seed that generates registry private key (optional, only if you want to update the registry entry with skylink)"
required: false
registry-datakey:
description: 'Registry datakey to use when updating the registry entry'
description: "Registry datakey to use when updating the registry entry"
required: true
default: 'skylink.txt'
default: "skylink.txt"
portal-url:
description: 'Skynet portal api url'
description: "Skynet portal api url"
required: true
default: 'https://siasky.net'
default: "https://siasky.net"
outputs:
skylink:
description: 'Uploaded resource skylink'
description: "Uploaded resource skylink"
skylink-url:
description: 'Uploaded resource skylink url'
description: "Uploaded resource skylink url"
resolver-skylink:
description: 'Resolver skylink pointing to uploaded resource'
description: "Resolver skylink pointing to uploaded resource"
resolver-skylink-url:
description: 'Resolver skylink url (as a subdomain)'
description: "Resolver skylink url (as a subdomain)"
runs:
using: 'node12'
using: "node12"
main: index.js
21 changes: 20 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,32 @@ function outputAxiosErrorMessage(error) {
}
}

function prepareUploadOptions() {
const options = {};

if (core.getInput("try-files")) {
// transform try-files input which is space separated list
// of file paths into an array of those paths
options.tryFiles = core.getInput("try-files").split(/\s+/);
}

if (core.getInput("not-found-page")) {
// transform not-found-page input which is a single file path into
// an object with a 404 key and its value being the specified path
options.errorPages = { 404: core.getInput("not-found-page") };
}

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(
core.getInput("upload-dir")
core.getInput("upload-dir"),
prepareUploadOptions()
);

// generate base32 skylink url from base64 skylink
Expand Down

0 comments on commit 158dc2d

Please sign in to comment.