From 94db9872dbf34d93611e449e3fa5e3bfac32ef19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Mon, 30 Sep 2024 19:14:33 +0200 Subject: [PATCH] add flake.nix and adjust Jenkinsfile to use Nix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit More deterministic and stable build. Also adde `build.json` for easy version checking. Signed-off-by: Jakub SokoĊ‚owski --- Jenkinsfile | 22 +++++++++++++--------- README.md | 9 +++++++++ flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Jenkinsfile b/Jenkinsfile index 84c4f1cf0..4eae60bad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,6 @@ +#!/usr/bin/env groovy +library 'status-jenkins-lib@v1.9.10' + pipeline { agent { label 'linux' @@ -22,23 +25,24 @@ pipeline { stages { stage('Deps') { - steps { - sh 'npm install' - } + steps { script { + nix.develop('npm install') + } } } stage('Build') { - steps { - sh 'npx quartz build' - } + steps { script { + nix.develop('npx quartz build') + jenkins.genBuildMetaJSON('public/build.json') + } } } stage('Publish Prod') { - steps { + steps { script { sshagent(credentials: ['status-im-auto-ssh']) { - sh 'ghp-import -p public' + nix.develop('ghp-import -c roadmap.vac.dev -p public', pure: false) } - } + } } } } } diff --git a/README.md b/README.md index 522808af0..b4b9de613 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,14 @@ This repository is built and served to https://roadmap.vac.co If you see a type or broken link, PRs are always welcome :) If there is information you'd like to see included that isn't here, create and issue :) +## CI/CD + +[CI builds](https://ci.infra.status.im/job/website/job/roadmap.vac.dev/) `master` and pushes to `gh-pages` branch, which is hosted at . + +The hosting is done using [Caddy server with Git plugin for handling GitHub webhooks](https://github.com/status-im/infra-misc/blob/master/ansible/roles/caddy-git). + +Information about deployed build can be also found in `/build.json` available on the website. + ### Using Obsidian Quartz is created to serve a static site off of an [Obsidian](https://obsidian.md) vault, and thus is the preferred way to manage content locally. In order for all it to function properly, a few things need to be done properly. @@ -34,3 +42,4 @@ In order to use the templates in the `Templates` folder for auto populating comm - assign whichever templates you want to be triggered when a new file is created in a given folder. Refer the [Templater documentation](https://silentvoid13.github.io/Templater/) for how to create your own templates. + diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..76a6f0f50 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1721548954, + "narHash": "sha256-7cCC8+Tdq1+3OPyc3+gVo9dzUNkNIQfwSDJ2HSi2u3o=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63d37ccd2d178d54e7fb691d7ec76000740ea24a", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..09f90c5fb --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "Flake file for website build"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-24.05"; + }; + + outputs = + { self, nixpkgs }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forEachSystem = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = forEachSystem (system: import nixpkgs { inherit system; }); + in + rec { + formatter = forEachSystem (system: pkgsFor.${system}.nixpkgs-fmt); + + devShells = forEachSystem (system: { + default = pkgsFor.${system}.mkShellNoCC { + packages = with pkgsFor.${system}.buildPackages; [ + yarn # 1.22.22 + nodejs_20 # 20.15.1 + git # 2.44.1 + openssh # 9.7p1 + ghp-import # 2.1.0 + ]; + }; + }); + }; +}