Skip to content

Commit ee66679

Browse files
authored
Create a Zip File with GitHub Actions (#82)
1 parent 4df2322 commit ee66679

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@ jobs:
1414
- name: Install Nix
1515
uses: cachix/install-nix-action@v12
1616

17-
- name: Build Executable
18-
run: nix-build
19-
2017
- name: Build Site
21-
run: result/bin/haskell-org-site build
18+
# we run the checks as a separate step
19+
run: nix build -f . built -o built-site --arg doCheck false
2220

2321
- name: Check Links
24-
run: nix-shell --command 'linkchecker _site'
22+
run: nix run --quiet -f . linkchecker -c linkchecker built-site
23+
24+
- uses: actions/upload-artifact@v2
25+
with:
26+
name: www.haskell.org
27+
path: built-site* # Uses glob pattern because
28+
# actions/upload-artifact@v2 gets
29+
# confused by symlinks otherwise
30+
#
31+
# See:
32+
# https://github.com/actions/upload-artifact/issues/92

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ dist-newstyle
99

1010
# Nix
1111
result*
12+
built-site

default.nix

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
, pkgs ?
44
import (builtins.fetchTarball {
55
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
6-
}) {}
6+
}) {}
7+
, doCheck ? true
78
}:
89

910
let
@@ -26,6 +27,7 @@ let
2627
"js/*"
2728
"img/*"
2829
".git"
30+
".github"
2931
] ./.;
3032
modifier = drv: pkgs.haskell.lib.overrideCabal drv (attrs: {
3133
buildTools = with pkgs.haskell.packages.${compiler}; (attrs.buildTools or []) ++ [
@@ -50,30 +52,29 @@ let
5052

5153
built = pkgs.stdenv.mkDerivation {
5254
name = "haskell.org";
55+
inherit doCheck;
56+
5357
src = gitignore.gitignoreSource [
5458
".git"
5559
"*.cabal"
5660
"*.hs"
61+
".github"
5762
] ./.;
5863
buildInputs = [ builder pkgs.linkchecker ];
64+
5965
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
6066
LC_ALL = "C.UTF-8";
61-
installPhase = ''
62-
echo ""
63-
echo " Building static site..."
64-
echo ""
65-
haskell-org-site build
66-
echo ""
67-
echo " Checking for bad links..."
68-
echo ""
67+
68+
buildPhase = ''
69+
${builder}/bin/haskell-org-site build
70+
'';
71+
checkPhase = ''
6972
linkchecker _site
70-
echo ""
71-
echo " Copying static site to $out..."
73+
'';
74+
installPhase = ''
7275
cp -r _site $out
73-
echo " Build complete"
74-
echo ""
7576
'';
7677
};
7778
in
7879
if pkgs.lib.inNixShell then builder
79-
else { inherit builder built; }
80+
else { inherit builder built; inherit (pkgs) linkchecker; }

0 commit comments

Comments
 (0)