From b2beb39b9205ac15c6af041149548bddd00601c4 Mon Sep 17 00:00:00 2001 From: irl Date: Tue, 3 Jun 2025 16:48:47 +0100 Subject: [PATCH] feat: build and deploy with netlify --- .forgejo/workflows/build-and-deploy.yaml | 32 +++++++++++++ .gitignore | 4 +- flake.lock | 61 ++++++++++++++++++++++++ flake.nix | 31 ++++++++++++ netlify.toml | 21 ++++++++ 5 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 .forgejo/workflows/build-and-deploy.yaml create mode 100644 flake.lock create mode 100644 netlify.toml diff --git a/.forgejo/workflows/build-and-deploy.yaml b/.forgejo/workflows/build-and-deploy.yaml new file mode 100644 index 0000000..57c5059 --- /dev/null +++ b/.forgejo/workflows/build-and-deploy.yaml @@ -0,0 +1,32 @@ +name: Build and deploy + +on: + push: + branches: + - main + +jobs: + lint: + runs-on: docker + + container: + image: ghcr.io/catthehacker/ubuntu:runner-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Nix + uses: https://guardianproject.dev/actions/install-nix-action@v31 + + - name: Install npm dependencies + run: nix develop --command npm install + + - name: Login to Netlify + run: nix develop --command netlify login --auth $NETLIFY_AUTH_TOKEN + + - name: Run build + run: nix develop --command netlify build + + - name: Deploy + run: nix develop --command netlify deploy diff --git a/.gitignore b/.gitignore index e3f49ce..f4a29d1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ yarn-error.log* /.idea # Generated docs -/docs/api \ No newline at end of file +/docs/api +# Local Netlify folder +.netlify diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..887a767 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1748693115, + "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index e69de29..dca1251 100644 --- a/flake.nix +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + outputs = + { + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { + inherit system; + }; + in + with pkgs; + { + devShells.default = mkShell { + buildInputs = [ + git + netlify-cli + nodejs_22 + ]; + }; + } + ); +} diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..a5247b2 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,21 @@ +# example netlify.toml +[build] + command = "npm run build" + functions = "netlify/functions" + publish = "build" + + ## Uncomment to use this redirect for Single Page Applications like create-react-app. + ## Not needed for static site generators. + #[[redirects]] + # from = "/*" + # to = "/index.html" + # status = 200 + + ## (optional) Settings for Netlify Dev + ## https://github.com/netlify/cli/blob/main/docs/netlify-dev.md#project-detection + #[dev] + # command = "yarn start" # Command to start your dev server + # port = 3000 # Port that the dev server will be listening on + # publish = "dist" # Folder with the static content for _redirect file + + ## more info on configuring this file: https://ntl.fyi/file-based-build-config