ci: finish discommit
Some checks failed
Discord / discord commits (push) Has been cancelled

This commit is contained in:
matt1432 2023-12-22 16:20:10 -05:00
parent e0b87a1298
commit 38364b9b84
11 changed files with 36 additions and 9 deletions

View file

@ -0,0 +1,27 @@
name: Discord
on:
workflow_dispatch:
push:
paths:
- 'devices/oksys/*'
jobs:
discord_commits:
runs-on: ubuntu-latest
name: discord commits
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
steps:
- name: Checkout
uses: https://github.com/actions/checkout@v3
- name: setup-nix
uses: https://github.com/cachix/install-nix-action@v24
- name: update
working-directory: ./common/pkgs/discommit
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: nix run . $DISCORD_WEBHOOK

Binary file not shown.

Binary file not shown.

View file

@ -1,24 +1,24 @@
#!/usr/bin/env node
import { Commit } from 'commit'; // Custom type import { Commit } from 'commit'; // Custom type
import fetch from 'node-fetch'; import fetch from 'node-fetch';
const DATA = { const DATA = {
env: {...process.env}, sha: process.env.GITHUB_SHA,
webhook: process.argv[2], // get it from env? webhook: process.argv[2],
}; };
const allCommits = await (await fetch('https://git.nelim.org/api/v1/repos/matt1432/nixos-configs/commits')).json() as Array<Commit>; const commitInfo = await (await fetch(`https://git.nelim.org/api/v1/repos/matt1432/nixos-configs/git/commits/${DATA.sha}`)).json() as Commit;
const last = allCommits[0];
const commit = JSON.stringify({ const commit = JSON.stringify({
content: null, content: null,
embeds: [{ embeds: [{
title: 'New commit containing changes to server configs:', title: 'New commit containing changes to server configs:',
description: last.commit.message, description: commitInfo.commit.message,
url: last.url, url: commitInfo.url,
author: { author: {
name: last.author.username, name: commitInfo.author.username,
icon_url: last.author.avatar_url, icon_url: commitInfo.author.avatar_url,
}, },
}], }],
// Diff: await (await fetch(`${last['url']}.diff`)).text() // Diff: await (await fetch(`${last['url']}.diff`)).text()