From 57bcedf8e07b0ccd1ad2cb50bb6aab6539f0ea5c Mon Sep 17 00:00:00 2001 From: Yvan Sraka Date: Mon, 13 Mar 2023 22:35:43 +0100 Subject: [PATCH] Use GitHub Pages to serve statically the bootstrap shell curl https://input-output-hk.github.io/devx | sh --- .github/workflows/gh-pages.yml | 43 ++++++++++++++++++++++ gh-pages/bootstrap.sh | 65 ++++++++++++++++++++++++++++++++++ gh-pages/index.html | 1 + 3 files changed, 109 insertions(+) create mode 100644 .github/workflows/gh-pages.yml create mode 100644 gh-pages/bootstrap.sh create mode 120000 gh-pages/index.html diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 00000000..d676ff29 --- /dev/null +++ b/.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 diff --git a/gh-pages/bootstrap.sh b/gh-pages/bootstrap.sh new file mode 100644 index 00000000..2c5a4468 --- /dev/null +++ b/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 < /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 +# +# else +# curl + import + launch +# fi +# +# ... rather than? +nix develop "github:yvan-sraka/static-closure#$1" --impure --no-write-lock-file --refresh --accept-flake-config diff --git a/gh-pages/index.html b/gh-pages/index.html new file mode 120000 index 00000000..eba53897 --- /dev/null +++ b/gh-pages/index.html @@ -0,0 +1 @@ +bootstrap.sh \ No newline at end of file