Skip to content

Commit f81f03f

Browse files
committed
Rewrite github workflow to use flakes
1 parent 77f1862 commit f81f03f

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

.github/workflows/deploy.yml

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Deploy to Gihub Pages
32

43
on:
@@ -16,24 +15,17 @@ jobs:
1615
submodules: true
1716
fetch-depth: 0
1817
lfs: true
19-
- name: Checkout LFS objects
20-
run: git lfs checkout
21-
22-
- name: Setup Hugo
23-
uses: peaceiris/actions-hugo@v2
24-
with:
25-
hugo-version: 'latest'
26-
extended: true
27-
28-
- name: Build
29-
run: hugo --minify
18+
- name: Install Nix
19+
uses: cachix/install-nix-action@v17
20+
- name: Build site
21+
run: nix build
3022

3123
- name: Deploy
3224
uses: peaceiris/actions-gh-pages@v3
3325
if: github.ref == 'refs/heads/main'
3426
with:
3527
github_token: ${{ secrets.GITHUB_TOKEN }}
36-
publish_dir: ./public
28+
publish_dir: ./result
3729
cname: allthingsembedded.com
3830

3931
deploy-staging:
@@ -47,19 +39,15 @@ jobs:
4739
- name: Checkout LFS objects
4840
run: git lfs checkout
4941

50-
- name: Setup Hugo
51-
uses: peaceiris/actions-hugo@v2
52-
with:
53-
hugo-version: 'latest'
54-
extended: true
55-
56-
- name: Build
57-
run: hugo --minify -D --baseURL https://allthingsembedded.com/staging-web
42+
- name: Install Nix
43+
uses: cachix/install-nix-action@v17
44+
- name: Build site
45+
run: nix build .#allthingsembedded-staging
5846

5947
- name: Deploy
6048
uses: peaceiris/actions-gh-pages@v3
6149
if: github.ref == 'refs/heads/main'
6250
with:
63-
publish_dir: ./public
51+
publish_dir: ./result
6452
external_repository: allthingsembedded/staging-web
6553
personal_token: ${{ secrets.PERSONAL_TOKEN }}

flake.nix

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,42 @@
3131
in
3232
fn pkgs
3333
);
34+
35+
buildHugoPackage = { pkgs, pname, version, src, extraBuildArgs ? "" }: (pkgs.stdenvNoCC.mkDerivation {
36+
inherit pname version src;
37+
38+
nativeBuildInputs = [
39+
pkgs.hugo
40+
];
41+
42+
buildPhase = ''
43+
mkdir -p themes/even/
44+
cp -r ${even-theme} themes/even
45+
hugo ${extraBuildArgs}
46+
'';
47+
48+
installPhase = ''
49+
cp -r public $out
50+
'';
51+
});
52+
3453
in
3554
{
3655
packages = forEachSystem (pkgs: rec {
37-
allthingsembedded = pkgs.stdenvNoCC.mkDerivation {
56+
allthingsembedded = buildHugoPackage {
57+
inherit pkgs;
3858
pname = "allthingsembedded";
3959
version = "1.0.0";
40-
4160
src = self;
61+
extraBuildArgs = "--minify";
62+
};
4263

43-
nativeBuildInputs = [
44-
pkgs.hugo
45-
];
46-
47-
buildPhase = ''
48-
mkdir -p themes/even/
49-
cp -r ${even-theme} themes/even
50-
hugo
51-
'';
52-
53-
installPhase = ''
54-
cp -r public $out
55-
'';
64+
allthingsembedded-staging = buildHugoPackage {
65+
inherit pkgs;
66+
pname = "allthingsembedded";
67+
version = "1.0.0";
68+
src = self;
69+
extraBuildArgs = "--minify -D --baseURL https://allthingsembedded.com/staging-web";
5670
};
5771

5872
default = allthingsembedded;

0 commit comments

Comments
 (0)