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 122 additions and 1250 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

View 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
}

View 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
];
};
});
};
}

View file

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

File diff suppressed because it is too large Load diff

View file

@ -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
];
};
});
};
}