Skip to content

Commit dabfe75

Browse files
committedJun 4, 2024
Reapply "Build website with nix"
This reverts commit 0066df8.
1 parent 0066df8 commit dabfe75

File tree

7 files changed

+123
-34
lines changed

7 files changed

+123
-34
lines changed
 

‎.github/workflows/jekyll-master.yml

+4-15
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,13 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v3
15-
- name: Install Bundler
16-
run: sudo gem install bundler
17-
- name: Cache bundle
18-
uses: actions/cache@v3
19-
with:
20-
path: vendor/bundle
21-
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
22-
restore-keys: |
23-
${{ runner.os }}-gems-
24-
- name: Install Jekyll
25-
run: bundle install
15+
- uses: DeterminateSystems/nix-installer-action@main
16+
- uses: DeterminateSystems/magic-nix-cache-action@main
2617
- name: Build the site with Jekyll
27-
run: |
28-
bundle exec jekyll build --future
29-
18+
run: nix build
3019
- name: Upload
3120
run: |
3221
mkdir -p "$HOME/.ssh"
3322
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
3423
chmod 600 "$HOME/.ssh/key"
35-
rsync -avzh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/_site/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/_site"
24+
rsync -rLtvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/result/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/_site"

‎.github/workflows/jekyll-preview.yml

+8-17
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,19 @@ jobs:
1414
export PULLREQUEST_ID=$(echo "${{ github.ref }}" | cut -d "/" -f3)
1515
echo "prid=$PULLREQUEST_ID" >> $GITHUB_OUTPUT
1616
if [ $(expr length "${{ secrets.USERNAME }}") -gt "1" ]; then echo "uploadtoserver=true" >> $GITHUB_OUTPUT; fi
17-
- name: Install Bundler
18-
run: sudo gem install bundler
19-
- name: Cache bundle
20-
uses: actions/cache@v3
21-
with:
22-
path: vendor/bundle
23-
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
24-
restore-keys: |
25-
${{ runner.os }}-gems-
26-
- name: Install Jekyll
27-
run: bundle install
17+
- uses: DeterminateSystems/nix-installer-action@main
18+
- uses: DeterminateSystems/magic-nix-cache-action@main
19+
- run: |
20+
echo "baseurl: /${{ steps.prepare.outputs.prid }}" >> _config.yml
2821
- name: Build the site with Jekyll
29-
run: |
30-
bundle exec jekyll build --future --baseurl "/${{ steps.prepare.outputs.prid }}"
31-
mkdir ${{ steps.prepare.outputs.prid }}
22+
run: nix build
3223

3324
- name: Upload preview
3425
run: |
3526
mkdir -p "$HOME/.ssh"
3627
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
3728
chmod 600 "$HOME/.ssh/key"
38-
rsync -avzh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/_site/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/staging/${{ steps.prepare.outputs.prid }}/"
29+
rsync -rLtvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/result/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/staging/${{ steps.prepare.outputs.prid }}/"
3930
4031
- name: "Post links to details"
4132
id: details
@@ -54,8 +45,8 @@ jobs:
5445
#check if comment already exists, if not post it
5546
export GITHUB_API_URL="https://api.github.com/repos/deltachat/deltachat-pages/issues/${{ steps.prepare.outputs.prid }}/comments"
5647
export RESPONSE=$(curl -L --header "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28")
57-
echo $RESPONSE > result
58-
grep -v '"Check out the page preview at https://staging.delta.chat/' result && echo "comment=true" >> $GITHUB_OUTPUT || true
48+
echo $RESPONSE > response
49+
grep -v '"Check out the page preview at https://staging.delta.chat/' response && echo "comment=true" >> $GITHUB_OUTPUT || true
5950
- name: "Post link to comments"
6051
if: steps.details.outputs.comment
6152
uses: actions/github-script@v6

‎.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ build/
1616
# for an optional virtual env folder
1717
venv/
1818

19-
vendor/bundle
19+
vendor/bundle
20+
21+
# Nix output.
22+
result

‎README.md

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ Testing changes
4343
the forked website will then be available at
4444
`https://<your-username>.github.io/deltachat-pages/`
4545

46+
- If you have Nix installed,
47+
you can build website preview in `result/` with `nix build`
48+
or run `nix develop` and start `jekyll serve` in development shell
49+
to have live preview at http://127.0.0.1:4000/en/
50+
If you don't have Nix installed,
51+
you can install it with [The Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer).
52+
4653
- Alternatively, [install Jekyll](https://jekyllrb.com/docs/installation/)
4754
on your local machive, run `bundle install` in this directory,
4855
and execute `bundle exec jekyll serve`.

‎_sass/_base.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ code {
237237
h1,h2,h3,h4,h5,h6 {
238238
&:hover {
239239
.anchor::before {
240-
content: "🔗"
240+
content: "\1F517"
241241
}
242242
}
243243
}

‎flake.lock

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
description = "Jekyll website template";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils, ... }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = nixpkgs.legacyPackages.${system};
13+
in
14+
{
15+
formatter = pkgs.nixpkgs-fmt;
16+
devShells.default = pkgs.mkShell {
17+
buildInputs = [
18+
pkgs.ruby
19+
pkgs.jekyll
20+
pkgs.rubyPackages.jekyll-sitemap
21+
];
22+
};
23+
24+
packages.default = pkgs.stdenv.mkDerivation {
25+
name = "deltachat-pages";
26+
src = ./.;
27+
buildInputs = [
28+
pkgs.ruby
29+
pkgs.jekyll
30+
pkgs.rubyPackages.jekyll-sitemap
31+
];
32+
buildPhase = ''
33+
jekyll build
34+
'';
35+
installPhase = ''cp -r _site $out'';
36+
};
37+
});
38+
}

0 commit comments

Comments
 (0)
Please sign in to comment.