From 7a9a7f56d95565263d9e98385f78871235681c27 Mon Sep 17 00:00:00 2001 From: markoburcul Date: Mon, 28 Oct 2024 11:35:53 +0100 Subject: [PATCH] build: add jenkinsfile and flake file To be able to deploy site we need a pipeline to build it and publish it to a branch from which our caddy-git service will pull for changes. All of this will be done using nix flake to ease out the build/development process. Referenced issue: https://github.com/status-im/status-network-docs/issues/1 Signed-off-by: markoburcul --- Jenkinsfile | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 10 +++++++++ flake.lock | 26 +++++++++++++++++++++++ flake.nix | 33 ++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 Jenkinsfile create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..15625d2 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,59 @@ +#!/usr/bin/env groovy +library 'status-jenkins-lib@v1.9.13' + +pipeline { + agent { label 'linux' } + + options { + disableConcurrentBuilds() + /* manage how many builds we keep */ + buildDiscarder(logRotator( + numToKeepStr: '20', + daysToKeepStr: '30', + )) + } + + environment { + GIT_COMMITTER_NAME = 'status-im-auto' + GIT_COMMITTER_EMAIL = 'auto@status.im' + } + + stages { + stage('Install') { + steps { + script { + nix.develop('yarn install') + } + } + } + + stage('Build') { + steps { + script { + nix.develop('yarn build') + jenkins.genBuildMetaJSON('build/build.json') + } + } + } + + stage('Publish') { + steps { + sshagent(credentials: ['status-im-auto-ssh']) { + script { + nix.develop(""" + ghp-import \ + -b deploy-master \ + -c docs.status.network \ + -p build + """ + ) + } + } + } + } + } + + post { + cleanup { cleanWs() } + } +} \ No newline at end of file diff --git a/README.md b/README.md index 86d4a6c..03a8f5b 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Welcome to the official documentation for Status Network! This repository contai - [Yarn](https://yarnpkg.com/) (v1 or higher) - [Git](https://git-scm.com/) +If you are familiar with using [Nix shell](https://nix.dev/manual/nix/2.17/command-ref/new-cli/nix3-develop) all of the dependencies will be installed by just running `nix develop` from within this repository which will spawn a new shell. + ### Installation ```bash @@ -40,6 +42,14 @@ yarn build This command generates static content into the `build` directory and can be served using any static contents hosting service. +## CI/CD + +- [CI builds](https://ci.infra.status.im/job/website/job/docs.status.network/) `master` and pushes to `deploy-master` 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. + ## 📝 Contributing We welcome contributions from the community! Here's how you can help improve our documentation: diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..538a182 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1729973466, + "narHash": "sha256-knnVBGfTCZlQgxY1SgH0vn2OyehH9ykfF8geZgS95bk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "cd3e8833d70618c4eea8df06f95b364b016d4950", + "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 0000000..dc48a3c --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + 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 + git # 2.44.1 + openssh # 9.7p1 + nodejs_20 # v20.15.1 + ghp-import # 2.1.0 + ]; + }; + }); + }; +} \ No newline at end of file