Skip to content

Commit

Permalink
Add Actions File
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Oct 30, 2024
1 parent b94f6df commit f8d46fb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import fs from 'node:fs';
import { Health } from './src/types.js';

if (!process.env.GITHUB_ISSUE) throw new Error('GITHUB_ISSUE Env Var must be set')

const issue = JSON.parse(process.env.GITHUB_ISSUE)

let health = Health.GREEN;

const labels = issue.labels.map((label) => { return label.description });

if (labels.includes('red')) health = Health.RED;
if (labels.includes('yellow')) health = Health.YELLOW;

if (!fs.exists(new URL('issues/', import.meta.url))){
fs.mkdirSync(new URL('issues/', import.meta.url));
}

fs.writeFileSync(new URL(`issues/${issue.number}`, import.meta.url), JSON.stringify({
id: issue.number,
username: issue.user.login,
health,
start: issue.created_at,
end: issue.closed_at || undefined,
title: issue.title,
body: issue.body
}, null, 4));

0 comments on commit f8d46fb

Please sign in to comment.