Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reapply "Build website with nix" #903

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions .github/workflows/jekyll-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,13 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Install Bundler
run: sudo gem install bundler
- name: Cache bundle
uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Jekyll
run: bundle install
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build the site with Jekyll
run: |
bundle exec jekyll build --future

run: nix build
- name: Upload
run: |
mkdir -p "$HOME/.ssh"
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
chmod 600 "$HOME/.ssh/key"
rsync -avzh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/_site/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/_site"
rsync -rILvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/result/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/_site"
25 changes: 8 additions & 17 deletions .github/workflows/jekyll-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,19 @@ jobs:
export PULLREQUEST_ID=$(echo "${{ github.ref }}" | cut -d "/" -f3)
echo "prid=$PULLREQUEST_ID" >> $GITHUB_OUTPUT
if [ $(expr length "${{ secrets.USERNAME }}") -gt "1" ]; then echo "uploadtoserver=true" >> $GITHUB_OUTPUT; fi
- name: Install Bundler
run: sudo gem install bundler
- name: Cache bundle
uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install Jekyll
run: bundle install
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
echo "baseurl: /${{ steps.prepare.outputs.prid }}" >> _config.yml
- name: Build the site with Jekyll
run: |
bundle exec jekyll build --future --baseurl "/${{ steps.prepare.outputs.prid }}"
mkdir ${{ steps.prepare.outputs.prid }}
run: nix build

- name: Upload preview
run: |
mkdir -p "$HOME/.ssh"
echo "${{ secrets.KEY }}" > "$HOME/.ssh/key"
chmod 600 "$HOME/.ssh/key"
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 }}/"
rsync -rILvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/result/ "${{ secrets.USERNAME }}@delta.chat:/var/www/html/staging/${{ steps.prepare.outputs.prid }}/"

- name: "Post links to details"
id: details
Expand All @@ -54,8 +45,8 @@ jobs:
#check if comment already exists, if not post it
export GITHUB_API_URL="https://api.github.com/repos/deltachat/deltachat-pages/issues/${{ steps.prepare.outputs.prid }}/comments"
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")
echo $RESPONSE > result
grep -v '"Check out the page preview at https://staging.delta.chat/' result && echo "comment=true" >> $GITHUB_OUTPUT || true
echo $RESPONSE > response
grep -v '"Check out the page preview at https://staging.delta.chat/' response && echo "comment=true" >> $GITHUB_OUTPUT || true
- name: "Post link to comments"
if: steps.details.outputs.comment
uses: actions/github-script@v6
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ build/
# for an optional virtual env folder
venv/

vendor/bundle
vendor/bundle

# Nix output.
result
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ Testing changes
the forked website will then be available at
`https://<your-username>.github.io/deltachat-pages/`

- If you have Nix installed,
you can build website preview in `result/` with `nix build`
or run `nix develop` and start `jekyll serve` in development shell
to have live preview at http://127.0.0.1:4000/en/
If you don't have Nix installed,
you can install it with [The Determinate Nix Installer](https://github.com/DeterminateSystems/nix-installer).

- Alternatively, [install Jekyll](https://jekyllrb.com/docs/installation/)
on your local machive, run `bundle install` in this directory,
and execute `bundle exec jekyll serve`.
Expand Down
2 changes: 1 addition & 1 deletion _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ code {
h1,h2,h3,h4,h5,h6 {
&:hover {
.anchor::before {
content: "🔗"
content: "\1F517"
}
}
}
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
description = "Jekyll website template";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
formatter = pkgs.nixpkgs-fmt;
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.ruby
pkgs.jekyll
pkgs.rubyPackages.jekyll-sitemap
];
};

packages.default = pkgs.stdenv.mkDerivation {
name = "deltachat-pages";
src = ./.;
buildInputs = [
pkgs.ruby
pkgs.jekyll
pkgs.rubyPackages.jekyll-sitemap
];
buildPhase = ''
jekyll build
'';
installPhase = ''cp -r _site $out'';
};
});
}
Loading