parent
e0b87a1298
commit
38364b9b84
11 changed files with 122 additions and 1250 deletions
.forgejo/workflows
common/pkgs
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
|
27
common/pkgs/discommit/flake.lock
generated
Normal file
27
common/pkgs/discommit/flake.lock
generated
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1703013332,
|
||||||
|
"narHash": "sha256-+tFNwMvlXLbJZXiMHqYq77z/RfmpfpiI3yjL6o/Zo9M=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "54aac082a4d9bb5bbc5c4e899603abfb76a3f6d6",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
59
common/pkgs/discommit/flake.nix
Normal file
59
common/pkgs/discommit/flake.nix
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{
|
||||||
|
#inputs.main.url = "path:../../../";
|
||||||
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
#main,
|
||||||
|
nixpkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
#nixpkgs = main.inputs.nixpkgs;
|
||||||
|
supportedSystems = ["x86_64-linux"];
|
||||||
|
|
||||||
|
perSystem = attrs:
|
||||||
|
nixpkgs.lib.genAttrs supportedSystems (system: let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
in
|
||||||
|
attrs system pkgs);
|
||||||
|
|
||||||
|
in {
|
||||||
|
packages = perSystem (system: pkgs: {
|
||||||
|
discommit = pkgs.buildNpmPackage {
|
||||||
|
name = "discommit";
|
||||||
|
src = ./.;
|
||||||
|
npmDepsHash = "sha256-/Ryhmg7phHHWniWQock95wAJz4TNYDDsLBEXcICz9ao=";
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
typescript
|
||||||
|
nodejs_20
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
tsc -p tsconfig.json
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
mv node_modules package.json $out
|
||||||
|
|
||||||
|
chmod +x ./build/index.js
|
||||||
|
cp -a ./build/index.js $out/bin/discommit
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
default = self.packages.${system}.discommit;
|
||||||
|
});
|
||||||
|
|
||||||
|
formatter = perSystem (_: pkgs: pkgs.alejandra);
|
||||||
|
|
||||||
|
devShells = perSystem (_: pkgs: {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
packages = with pkgs; [
|
||||||
|
alejandra
|
||||||
|
git
|
||||||
|
nodejs_20
|
||||||
|
typescript
|
||||||
|
];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
|
@ -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()
|
1204
common/pkgs/discord-commits/flake.lock
generated
1204
common/pkgs/discord-commits/flake.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,37 +0,0 @@
|
||||||
{
|
|
||||||
inputs.main.url = "path:../../../";
|
|
||||||
|
|
||||||
outputs = {
|
|
||||||
self,
|
|
||||||
main,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
nixpkgs = main.inputs.nixpkgs;
|
|
||||||
supportedSystems = ["x86_64-linux"];
|
|
||||||
|
|
||||||
perSystem = attrs:
|
|
||||||
nixpkgs.lib.genAttrs supportedSystems (system: let
|
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
|
||||||
in
|
|
||||||
attrs system pkgs);
|
|
||||||
|
|
||||||
in {
|
|
||||||
packages = perSystem (system: pkgs: {
|
|
||||||
discord-commits = pkgs.callPackage ./nix;
|
|
||||||
default = self.packages.${system}.discord-commits;
|
|
||||||
});
|
|
||||||
|
|
||||||
formatter = perSystem (_: pkgs: pkgs.alejandra);
|
|
||||||
|
|
||||||
devShells = perSystem (_: pkgs: {
|
|
||||||
default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
alejandra
|
|
||||||
git
|
|
||||||
nodejs_20
|
|
||||||
typescript
|
|
||||||
];
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue