Skip to content

Commit

Permalink
fix envs in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bchamagne committed Apr 22, 2024
1 parent 3cac141 commit d633d0a
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 48 deletions.
52 changes: 30 additions & 22 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: 'Archethic Web'
description: 'This Github action lets you deploy any folder, file or static website to the Archethic Blockchain'
author: 'Archethic Foundation'
name: "Archethic Web"
description: "This Github action lets you deploy any folder, file or static website to the Archethic Blockchain"
author: "Archethic Foundation"

branding:
icon: 'arrow-up-circle'
color: 'black'
icon: "arrow-up-circle"
color: "black"

inputs:
seed: # Seed of the transaction chain
description: 'Seed of the transaction chain'
seed: # Seed of the transaction chain
description: "Seed of the transaction chain"
required: true

endpoint:
description: 'Endpoint of the network, default is https://testnet.archethic.net'
description: "Endpoint of the network, default is https://testnet.archethic.net"
required: true
default: 'https://testnet.archethic.net'
default: "https://testnet.archethic.net"

path:
description: 'Path of the folder/file/website, default ./'
description: "Path of the folder/file/website, default ./"
required: true
default: './'
default: "./"

keychainFundingService:
description: "Keychain's service to funds the website transactions"

Expand All @@ -33,18 +33,26 @@ inputs:
sslKey:
description: "Website's SSL key"

sendTransactionTimeout:
description: "Timeout for the send_transaction query (default=60000)"

percentageOfConfirmations:
description: "1-100 % of the confirmations success to mark the transaction as valid (default=50)"

outputs:
transaction-address: # Url where the folder/file/website is hosted
description: 'Url where the folder/file/website is hosted'
description: "Url where the folder/file/website is hosted"

runs:
using: 'docker'
image: 'Dockerfile'
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.seed }}
- ${{ inputs.endpoint }}
- ${{ inputs.path }}
- ${{ inputs.keychainFundingService }}
- ${{ inputs.keychainWebsiteService }}
- ${{ inputs.sslKey }}
- ${{ inputs.sslCertificateFile }}
- ${{ inputs.seed }}
- ${{ inputs.endpoint }}
- ${{ inputs.path }}
- ${{ inputs.keychainFundingService }}
- ${{ inputs.keychainWebsiteService }}
- ${{ inputs.sslKey }}
- ${{ inputs.sslCertificateFile }}
- ${{ inputs.sendTransactionTimeout}}
- ${{ inputs.percentageOfConfirmations}}
68 changes: 42 additions & 26 deletions aeweb_action/index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,58 @@
import { handler } from "./src/action.js"
import path from "path"
import fs from "fs"
import { handler } from "./src/action.js";
import path from "path";
import fs from "fs";

const SEED = process.env["INPUT_SEED"]
const ENDPOINT = process.env["INPUT_ENDPOINT"]
const PATH = process.env["GITHUB_WORKSPACE"] ? path.join(process.env["GITHUB_WORKSPACE"], process.env["INPUT_PATH"]) : process.env["INPUT_PATH"]
const KEYCHAIN_FUNDING_SERVICE = process.env["INPUT_KEYCHAINFUNDINGSERVICE"]
const KEYCHAIN_WEBSITE_SERVICE = process.env["INPUT_KEYCHAINWEBSITESERVICE"]
const SSL_CERTIFICATE_FILE = process.env["INPUT_SSLCERTIFICATEFILE"]
const SSL_KEY = process.env["INPUT_SSLKEY"]
const SEND_TRANSACTION_TIMEOUT = process.env["SEND_TRANSACTION_TIMEOUT"] || 60000
const PERCENTAGE_OF_CONFIRMATIONS = process.env["PERCENTAGE_OF_CONFIRMATIONS"] || 50
const SEED = process.env["INPUT_SEED"];
const ENDPOINT = process.env["INPUT_ENDPOINT"];
const PATH = process.env["GITHUB_WORKSPACE"]
? path.join(process.env["GITHUB_WORKSPACE"], process.env["INPUT_PATH"])
: process.env["INPUT_PATH"];
const KEYCHAIN_FUNDING_SERVICE = process.env["INPUT_KEYCHAINFUNDINGSERVICE"];
const KEYCHAIN_WEBSITE_SERVICE = process.env["INPUT_KEYCHAINWEBSITESERVICE"];
const SSL_CERTIFICATE_FILE = process.env["INPUT_SSLCERTIFICATEFILE"];
const SSL_KEY = process.env["INPUT_SSLKEY"];
const SEND_TRANSACTION_TIMEOUT =
process.env["INPUT_SENDTRANSACTIONTIMEOUT"] || 60000;
const PERCENTAGE_OF_CONFIRMATIONS =
process.env["INPUT_PERCENTAGEOFCONFIRMATIONS"] || 50;

if (!SEED) {
console.log("INPUT_SEED argument needs to be provided")
process.exit(1)
console.log("INPUT_SEED argument needs to be provided");
process.exit(1);
}

if (!ENDPOINT) {
console.log("INPUT_ENDPOINT argument needs to be provided")
process.exit(1)
console.log("INPUT_ENDPOINT argument needs to be provided");
process.exit(1);
}

if (!PATH) {
console.log("INPUT_PATH argument needs to be provided")
process.exit(1)
console.log("INPUT_PATH argument needs to be provided");
process.exit(1);
}

let sslCertificate
let sslCertificate;
if (SSL_CERTIFICATE_FILE) {
sslCertificate = fs.readFileSync(path.join(PATH, SSL_CERTIFICATE_FILE), 'utf8')
sslCertificate = fs.readFileSync(
path.join(PATH, SSL_CERTIFICATE_FILE),
"utf8",
);
}

try {
await handler(SEED, PATH, ENDPOINT, KEYCHAIN_FUNDING_SERVICE, KEYCHAIN_WEBSITE_SERVICE, SSL_KEY, sslCertificate, SEND_TRANSACTION_TIMEOUT, PERCENTAGE_OF_CONFIRMATIONS)
process.exit(0)
}
catch (e) {
console.log(e)
process.exit(1)
await handler(
SEED,
PATH,
ENDPOINT,
KEYCHAIN_FUNDING_SERVICE,
KEYCHAIN_WEBSITE_SERVICE,
SSL_KEY,
sslCertificate,
SEND_TRANSACTION_TIMEOUT,
PERCENTAGE_OF_CONFIRMATIONS,
);
process.exit(0);
} catch (e) {
console.log(e);
process.exit(1);
}

0 comments on commit d633d0a

Please sign in to comment.