Update CI
This commit is contained in:
parent
243360dd70
commit
d090a37560
22
.github/workflows/build.yaml
vendored
Normal file
22
.github/workflows/build.yaml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: Build project
|
||||
run: nix build
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v2
|
||||
with:
|
||||
path: ./result/www
|
39
.github/workflows/deploy.yaml
vendored
39
.github/workflows/deploy.yaml
vendored
|
@ -1,25 +1,24 @@
|
|||
name: "Deploy"
|
||||
# Inspired by https://github.com/actions/starter-workflows/blob/main/pages/mdbook.yml
|
||||
name: Deploy
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [$default-branch]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v19
|
||||
with:
|
||||
github_access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: cachix/cachix-action@v12
|
||||
with:
|
||||
name: erratic-gate
|
||||
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||
|
||||
- run: nix build
|
||||
- run: nix flake check
|
||||
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./dist
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v2
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ dist
|
|||
coverege
|
||||
idea
|
||||
.direnv
|
||||
result
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"trailingComma": "none",
|
||||
"singleQuote": true,
|
||||
"printWidth": 80,
|
||||
"tabWidth": 4
|
||||
"tabWidth": 2
|
||||
}
|
||||
|
|
16
build.js
16
build.js
|
@ -1,19 +1,20 @@
|
|||
import * as esbuild from 'esbuild'
|
||||
import { htmlPlugin } from '@craftamap/esbuild-plugin-html'
|
||||
import { sassPlugin } from 'esbuild-sass-plugin'
|
||||
import * as fs from 'fs'
|
||||
|
||||
const production = process.env.NODE_ENV === 'production'
|
||||
const serve = process.env.ESBUILD_SERVE === '1'
|
||||
|
||||
const ctx = await esbuild.context({
|
||||
entryPoints: ['src/index.ts'],
|
||||
bundle: production,
|
||||
// minify: production,
|
||||
outdir: 'dist',
|
||||
minify: !serve,
|
||||
bundle: true,
|
||||
metafile: true,
|
||||
splitting: true,
|
||||
outdir: 'dist',
|
||||
format: 'esm',
|
||||
target: ['chrome100', 'firefox100'],
|
||||
target: ['es2020'],
|
||||
assetNames: 'assets/[name]-[hash]',
|
||||
loader: {
|
||||
'.svg': 'file'
|
||||
},
|
||||
|
@ -26,7 +27,6 @@ const ctx = await esbuild.context({
|
|||
favicon: 'public/favicon.ico',
|
||||
htmlTemplate: 'public/index.html',
|
||||
scriptLoading: 'module'
|
||||
// inline: { js: true }
|
||||
}
|
||||
]
|
||||
}),
|
||||
|
@ -37,4 +37,8 @@ const ctx = await esbuild.context({
|
|||
if (serve) {
|
||||
const { port, host } = await ctx.serve({ servedir: 'dist' })
|
||||
console.log(`Serving on ${host}:${port}`)
|
||||
} else {
|
||||
await ctx.rebuild()
|
||||
await ctx.dispose()
|
||||
fs.cpSync('./dist/index.html', './dist/404.html') // Needed to please github pages
|
||||
}
|
||||
|
|
35
flake.nix
35
flake.nix
|
@ -3,17 +3,43 @@
|
|||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem
|
||||
(system:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in
|
||||
{
|
||||
rec {
|
||||
packages.erratic-gate = pkgs.buildNpmPackage {
|
||||
name = "erratic-gate";
|
||||
|
||||
buildInputs = [ pkgs.nodejs_18 ];
|
||||
|
||||
src = pkgs.lib.cleanSource ./.;
|
||||
npmDepsHash = "sha256-f5mw6IjkhZgsIuzCz9d7DvoAdceY1y+yWXn1BOonsVI=";
|
||||
npmBuild = "npm run build";
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
cp -r dist $out/www
|
||||
'';
|
||||
};
|
||||
|
||||
packages.default = packages.erratic-gate;
|
||||
|
||||
devShells.default =
|
||||
pkgs.mkShell {
|
||||
buildInputs = with pkgs; with nodePackages_latest; [
|
||||
buildInputs = with pkgs;
|
||||
with nodePackages_latest; [
|
||||
nodejs
|
||||
];
|
||||
};
|
||||
|
||||
apps.compute-npm-dep-hash = {
|
||||
type = "app";
|
||||
program = pkgs.lib.getExe (pkgs.writeShellApplication {
|
||||
name = "generate-layout-previes";
|
||||
runtimeInputs = [ pkgs.prefetch-npm-deps ];
|
||||
text = "prefetch-npm-deps ./package-lock.json";
|
||||
});
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -29,3 +55,4 @@
|
|||
};
|
||||
# }}}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
User-agent: *
|
||||
Disallow: /server.js
|
||||
Disallow: /js
|
||||
Disallow: /css
|
Loading…
Reference in a new issue