Skip to content

Commit

Permalink
feat: add cid to the outputs (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Aug 17, 2023
1 parent 7c74665 commit acd500c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Copy the resulting value into Github Secrets for your project (or run `gh secret

The url of the published app - particularly useful if your repository doesn't have a fission.yaml file and you are using generated urls.

### `app_cid`
The content identifier of the published app.

## Troubleshooting

### Invalid key file provided
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ inputs:
outputs:
app_url:
description: "App URL for the published app."
app_cid:
description: "App CID."
runs:
using: "node16"
main: "dist/index.js"
31 changes: 27 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13684,11 +13684,34 @@ const runFission = (opts) => __awaiter(void 0, void 0, void 0, function* () {
defaultOpts.push(`-R ${remote}`);
}
const verbose = core.getBooleanInput("VERBOSE");
if (verbose) {
defaultOpts.push("--verbose");
}
// We need to pass --verbose to fission app publish to get the CID
defaultOpts.push("--verbose");
const execOptions = {
// Makes the actions silent by default, but we can override this with the listener below
silent: true,
};
let cid = undefined;
execOptions.listeners = {
stdline(data) {
console.log(data);
},
errline: (data) => {
if (verbose) {
console.log(data);
}
const regex = /Directory CID is (.+)/;
const match = data.match(regex);
if (match) {
cid = match[1];
}
}
};
const options = opts.concat(defaultOpts);
yield exec.exec("fission", options);
yield exec.exec("fission", options, execOptions);
if (cid) {
core.setOutput('app_cid', cid);
console.log(`🌐 https://dweb.link/ipfs/${cid}`);
}
});
exports.runFission = runFission;
const statusUpdate = (state, target_url = "") => __awaiter(void 0, void 0, void 0, function* () {
Expand Down
37 changes: 34 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,42 @@ export const runFission = async (opts: Array<string>) => {
}

const verbose = core.getBooleanInput("VERBOSE");
if (verbose) {
defaultOpts.push("--verbose");

// We need to pass --verbose to fission app publish to get the CID
defaultOpts.push("--verbose");

const execOptions: exec.ExecOptions = {
// Makes the actions silent by default, but we can override this with the listener below
silent: true,
}

let cid: string | undefined = undefined;

execOptions.listeners = {
stdline(data) {
console.log(data)
},

errline: (data: string) => {
if(verbose) {
console.log(data)
}

const regex = /Directory CID is (.+)/
const match = data.match(regex);

if (match) {
cid = match[1]
}
}
}

const options = opts.concat(defaultOpts);
await exec.exec("fission", options);
await exec.exec("fission", options, execOptions);
if(cid) {
core.setOutput('app_cid', cid)
console.log(`🌐 https://dweb.link/ipfs/${cid}`)
}
};

export const statusUpdate = async (
Expand Down

0 comments on commit acd500c

Please sign in to comment.