Skip to content

Commit

Permalink
Add flake and related GH workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Dec 17, 2024
1 parent bc311b8 commit 810af89
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 3 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/cachix-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Workflow to build and push the static hugo files to Cachix
name: 🛫 Build and push to Cachix

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/cachix-action@v14
with:
name: qgis-org
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build .#qgis-website
- run: nix flake check
37 changes: 37 additions & 0 deletions .github/workflows/flake-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update Nix Flake inputs

on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:

jobs:
test:
name: Update flakes and commit changes
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# This will allow us to trigger other workflows (cachix-build, etc.)
# when we commit changes using the git-auto-commit-action
token: ${{ secrets.PAT }}

- name: Install Nix
uses: cachix/install-nix-action@v25

- name: Run nix flake update
run: >
nix flake update
- name: '✉️ Commit'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Flakes updated and committed via a GitHub Action.'

2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/playwright-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: 🛠️ Setup Hugo
uses: peaceiris/actions-hugo@v3
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/update-feeds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ jobs:
if: github.repository_owner == 'qgis'
steps:
- name: '🛒 Checkout QGIS Website'
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main
path: ./qgis-website
# This will allow us to trigger other workflows (cachix-build, etc.)
# when we commit changes using the git-auto-commit-action
token: ${{ secrets.PAT }}

- name: '🐍 Setup Python'
uses: actions/setup-python@v3
Expand Down
59 changes: 59 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
description = "Development environment and build process for a Hugo app with Python requirements";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs = { self, nixpkgs }:
let
system = "x86_64-linux";

# Importing packages from nixpkgs
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true; # Allow unfree packages like VSCode if needed
};


mkDevShell = pkgs.mkShell {
packages = with pkgs; [
hugo # Hugo for building the website
vscode # VSCode for development
python312Packages.icalendar # Python packages
python312Packages.requests # Python packages
gnumake # GNU Make for build automation
];

shellHook = ''
export DIRENV_LOG_FORMAT=
echo "-----------------------"
echo "🌈 Your Hugo Dev Environment is ready."
echo "It provides hugo and vscode for use with the QGIS Website Project"
echo ""
echo "🪛 VSCode:"
echo "--------------------------------"
echo "Start vscode like this:"
echo ""
echo "./vscode.sh"
echo ""
echo "🪛 Hugo:"
echo "--------------------------------"
echo "Start Hugo like this:"
echo ""
echo "hugo server"
echo "-----------------------"
'';
};

in
{
devShells.x86_64-linux.default = mkDevShell;

packages = {
x86_64-linux = {
qgis-website = pkgs.callPackage ./package.nix {};
};
};
};
}
32 changes: 32 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ lib, stdenv, hugo, gnumake }:

stdenv.mkDerivation {
name = "qgis-website";
src = lib.cleanSourceWith {
src = ./.;
filter = (
path: type: (builtins.all (x: x != baseNameOf path) [
".git"
".github"
"flake.nix"
"package.nix"
])
);
};
buildInputs = [ hugo gnumake ];

buildPhase = ''
make deploy
'';

installPhase = ''
mkdir -p $out
cp -r public_www public_prod $out/
'';

meta = with lib; {
description = "A built QGIS website";
license = licenses.mit;
};
}

0 comments on commit 810af89

Please sign in to comment.