Skip to content

Commit

Permalink
ci: back to garnix
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Dec 16, 2023
1 parent bd2966d commit 93f19fd
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 179 deletions.
113 changes: 0 additions & 113 deletions .github/workflows/ci.yaml

This file was deleted.

60 changes: 47 additions & 13 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,53 @@
name: Push to image registry

on:
workflow_call:
check_suite:
types: [completed]
workflow_dispatch:

jobs:
build:
name: Build image

runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]

# https://github.com/sellout/bash-strict-mode/commit/9bf1d65c2f786a9887facfcb81e06d8b8b5f4667
if: github.event.check_suite.app.name == 'Garnix CI'
&& github.event.check_suite.conclusion == 'success'
&& github.event.check_suite.latest_check_runs_count >= 8
&& github.event.check_suite.head_branch == 'main'

steps:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v9

- name: Setup Nix cache
uses: DeterminateSystems/magic-nix-cache-action@v2

- name: Build Docker image
id: build
run: |
nix build -L --accept-flake-config .#container-${{ matrix.arch }}
[ ! -L result ] && exit 1
echo "path=$(realpath result)" >> "$GITHUB_OUTPUT"
- name: Upload image
uses: actions/upload-artifact@v3
with:
name: container-${{ matrix.arch }}
path: ${{ steps.build.outputs.path }}
if-no-files-found: error
retention-days: 1

push:
name: Push image

needs: build
runs-on: ubuntu-latest

permissions:
Expand All @@ -23,15 +64,10 @@ jobs:
- uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v9

- name: Setup Attic cache
uses: ryanccn/attic-action@v0
- name: Download images
uses: actions/download-artifact@v3
with:
endpoint: https://cache.mydadleft.me
cache: teawiebot
token: ${{ secrets.ATTIC_TOKEN }}
path: images

- name: Login to registry
uses: docker/login-action@v3
Expand All @@ -48,11 +84,9 @@ jobs:
architectures=("x86_64" "aarch64")
for arch in "${architectures[@]}"; do
nix build -L --accept-flake-config .#container-"$arch"
docker load < result
docker tag ${{ env.IMAGE_NAME }}:latest-"$arch" ${{ env.TAG }}-"$arch"
docker load < images/container-"$arch"/*.tar.gz
docker tag teawiebot:latest-"$arch" ${{ env.TAG }}-"$arch"
docker push ${{ env.TAG }}-"$arch"
rm result
done
docker manifest create ${{ env.TAG }} \
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/update-flake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ jobs:
update:
runs-on: ubuntu-latest

permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v4

Expand All @@ -22,11 +26,11 @@ jobs:
with:
commit-msg: "flake: update inputs"
pr-title: "flake: update inputs"
token: ${{ secrets.MERGE_TOKEN }}
token: ${{ github.token }}

- name: Enable auto-merge
shell: bash
run: gh pr merge --auto --rebase "$PR_ID"
env:
GH_TOKEN: ${{ secrets.MERGE_TOKEN }}
GH_TOKEN: ${{ github.token }}
PR_ID: ${{ steps.update.outputs.pull-request-number }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# teawie bot 🦀🦀🦀

[![Build status](https://img.shields.io/github/actions/workflow/status/getchoo/teawiebot/ci.yaml?style=flat-square&logo=github&label=Build%20status&color=5277c3)](https://github.com/getchoo/teawiebot/actions/workflows/ci.yaml)
[![built with garnix](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Fgarnix.io%2Fapi%2Fbadges%2Fgetchoo%2FteawieBot)](https://garnix.io)

okay so like basically, it's just a discord bot named "teawie" (so cool!!
and now in rust!!!)🚀🚀
Expand Down
21 changes: 0 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description = "teawie moment";

nixConfig = {
extra-substituters = ["https://cache.mydadleft.me/teawiebot"];
extra-trusted-public-keys = ["teawiebot:vp7AaQ042O/3326DMMtLF4MOUa5/kCBAq+YApy5GWXA="];
extra-substituters = ["https://cache.garnix.io"];
extra-trusted-public-keys = ["cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="];
};

inputs = {
Expand All @@ -27,11 +27,6 @@
proc-flake.url = "github:srid/proc-flake";
flake-root.url = "github:srid/flake-root";

nix2workflow = {
url = "github:getchoo/nix2workflow";
inputs.nixpkgs-lib.follows = "nixpkgs";
};

pre-commit = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
Expand All @@ -43,16 +38,13 @@
parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.pre-commit.flakeModule

inputs.proc-flake.flakeModule
inputs.flake-root.flakeModule

inputs.nix2workflow.flakeModule

./nix/ci.nix
./nix/deployment.nix
./nix/dev.nix
./nix/packages.nix
./nix/workflow.nix
];

systems = [
Expand Down
6 changes: 6 additions & 0 deletions garnix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
builds:
exclude: []
include:
- "checks.x86_64-linux.*"
- "packages.x86_64-linux.*"
- "devShells.x86_64-linux.default"
25 changes: 25 additions & 0 deletions nix/ci.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
perSystem = {
pkgs,
lib,
config,
...
}: {
/*
require packages, checks, and devShells for ci to be considered a success
also thanks DetSys for showing me i don't need to use runCommand, symlinkJoin, or linkFarm!
https://determinate.systems/posts/hydra-deployment-source-of-truth
*/

packages.ciGate = pkgs.writeText "ci-gate" ''
${
lib.concatMapStringsSep "\n" (s: toString (builtins.attrValues s)) [
config.checks
config.devShells
(builtins.removeAttrs config.packages ["default" "ciGate"])
]
}
'';
};
}
4 changes: 1 addition & 3 deletions nix/deployment.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
inputs',
...
}: let
name = "getchoo/teawiebot";

crossPkgsFor = lib.fix (finalAttrs: {
"x86_64-linux" = {
"x86_64" = pkgs.pkgsStatic;
Expand Down Expand Up @@ -70,7 +68,7 @@

containerFor = arch:
pkgs.dockerTools.buildLayeredImage {
inherit name;
name = "teawiebot";
tag = "latest-${arch}";
contents = [pkgs.dockerTools.caCertificates];
config.Cmd = [(wieFor arch)];
Expand Down
15 changes: 0 additions & 15 deletions nix/workflow.nix

This file was deleted.

0 comments on commit 93f19fd

Please sign in to comment.