Skip to content

Commit

Permalink
Use GitHub Pages to serve statically the bootstrap shell
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka committed Mar 16, 2023
1 parent 0720bc6 commit 57bcedf
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/gh-pages.yml
@@ -0,0 +1,43 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
# FIXME: disabled while working on it ...
# push:
# branches: ["main"]

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

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './gh-pages'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
65 changes: 65 additions & 0 deletions gh-pages/bootstrap.sh
@@ -0,0 +1,65 @@
#! /bin/bash
set -euo pipefail

# End-user DevX could also be potentially improved through this script: e.g,
# by helping new users to set up Nix using Determinate Systems new installer,
# or detect that it's used in a GA context and advise installing Nix with Cachix install Nix action.

# TODO: you can give it a try with ...
# curl --proto '=https' --tlsv1.2 -sSf -L https://yvan-sraka.github.io/devx/ | sh -s -- ghc8107-static-minimal

if ! command -v nix >/dev/null 2>&1; then
echo "This script requires nix to be installed; you don't appear to have nix available ..."
if [ "$GITHUB_ACTIONS" == "true" ]; then
echo "... and it seems that you run it inside a GitHub Action!
You can setup Nix using https://github.com/cachix/install-nix-action, e.g.:
- name: Install Nix with good defaults
uses: cachix/install-nix-action
with:
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io/ https://cache.nixos.org/"
# TODO: explain how to use the shell with something better than:
#
# - name: Add devx-shell
# run: |
# echo $PATH
# cat <<EOF > /usr/local/bin/devx-shell
# #!/bin/bash
# nix develop github:input-output-hk/devx#ghc8107-static-minimal \
# --command /usr/bin/bash <(echo 'eval "\$shellHook\"'; cat "$1")
# EOF
# chmod +x /usr/local/bin/devx-shell
# - name: Build
# shell: devx-shell {0}
# run: |
# cabal update
# cabal build
exit 1
else
echo "... we can run https://github.com/DeterminateSystems/nix-installer for you!"
echo "Do you want to install nix now? (y/n)"
read -r answer
case "$answer" in
y|Y)
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
;;
*)
echo "Feel free to install (or not) nix your way :)"
exit 1
;;
esac
fi
fi
# TODO: figure out the best way of doing ...
#
# if [[ -e /nix/store/...path-to-rc file ]]; then
# <launch directly>
# else
# curl + import + launch
# fi
#
# ... rather than?
nix develop "github:yvan-sraka/static-closure#$1" --impure --no-write-lock-file --refresh --accept-flake-config
1 change: 1 addition & 0 deletions gh-pages/index.html

0 comments on commit 57bcedf

Please sign in to comment.