Skip to content

Commit

Permalink
fix: correct code for build
Browse files Browse the repository at this point in the history
  • Loading branch information
steveoh committed Mar 29, 2024
1 parent 08a801a commit a11b68d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 54 deletions.
52 changes: 0 additions & 52 deletions src/action.ts

This file was deleted.

55 changes: 53 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
import { Action } from './action';
import * as core from '@actions/core';
import * as github from '@actions/github';
import { geocode } from './geocode';
import {
formatResults,
generateTokens,
getOctokit,
requiresAction,
} from './util';

Action.run();
export async function run() {
core.notice('Starting action');
try {
const { context } = github;
const payload = context.payload;
const commentBody = context.payload.comment!.body as string;

core.debug(JSON.stringify(payload));

if (payload?.comment?.id == null) {
core.setFailed('no comment found in payload');

return;
}

if (!requiresAction(payload, commentBody)) {
core.warning('no action required');

return;
}

core.notice('getting octokit');
const octokit = getOctokit();

core.notice('finding addresses');
const { addresses } = generateTokens(commentBody);
core.notice(`addresses: ${addresses}`);

const results = await geocode(addresses, core.getInput('API_KEY'));

core.notice('updating comments');
await octokit.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: payload.comment.id,
body: formatResults(results),
});
} catch (e) {
core.error(e);
core.setFailed(e.message);
}
}

run()

0 comments on commit a11b68d

Please sign in to comment.