2023-12-22 16:20:10 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
2023-12-22 03:06:15 -05:00
|
|
|
import { Commit } from 'commit'; // Custom type
|
|
|
|
import fetch from 'node-fetch';
|
|
|
|
|
|
|
|
const DATA = {
|
2023-12-22 16:20:10 -05:00
|
|
|
sha: process.env.GITHUB_SHA,
|
|
|
|
webhook: process.argv[2],
|
2023-12-22 03:06:15 -05:00
|
|
|
};
|
|
|
|
|
2023-12-22 16:20:10 -05:00
|
|
|
const commitInfo = await (await fetch(`https://git.nelim.org/api/v1/repos/matt1432/nixos-configs/git/commits/${DATA.sha}`)).json() as Commit;
|
2023-12-22 03:06:15 -05:00
|
|
|
|
|
|
|
const commit = JSON.stringify({
|
|
|
|
content: null,
|
|
|
|
embeds: [{
|
|
|
|
title: 'New commit containing changes to server configs:',
|
2023-12-22 16:20:10 -05:00
|
|
|
description: commitInfo.commit.message,
|
2023-12-24 16:28:26 -05:00
|
|
|
url: commitInfo.html_url,
|
2023-12-22 03:06:15 -05:00
|
|
|
author: {
|
2023-12-22 16:20:10 -05:00
|
|
|
name: commitInfo.author.username,
|
|
|
|
icon_url: commitInfo.author.avatar_url,
|
2023-12-22 03:06:15 -05:00
|
|
|
},
|
|
|
|
}],
|
2023-12-24 16:28:26 -05:00
|
|
|
// Diff: await (await fetch(`${commitInfo.url}.diff`)).text()
|
2023-12-22 03:06:15 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
const post = await fetch(`${DATA.webhook}?wait=true`, {
|
|
|
|
method: 'post',
|
|
|
|
body: commit,
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(await post.text());
|