This commit is contained in:
parent
e0b87a1298
commit
38364b9b84
11 changed files with 36 additions and 9 deletions
27
.forgejo/workflows/discord.yml
Normal file
27
.forgejo/workflows/discord.yml
Normal 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
|
BIN
common/pkgs/discommit/flake.lock
Normal file
BIN
common/pkgs/discommit/flake.lock
Normal file
Binary file not shown.
BIN
common/pkgs/discommit/flake.nix
Normal file
BIN
common/pkgs/discommit/flake.nix
Normal file
Binary file not shown.
|
@ -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()
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue