Skip to content

Commit

Permalink
direnv: add installer
Browse files Browse the repository at this point in the history
  • Loading branch information
iainelder committed Jun 23, 2023
1 parent f6f2675 commit 5379566
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/direnv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: direnv
on:
push:
paths:
- programs/direnv/install.bash
- .github/workflows/direnv.yml
schedule:
# Not at the start of an hour or a day to decreate the chance of delay.
# See schedule documentation.
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: "17 5 * * *"

workflow_dispatch:

jobs:
test_idempotent_installation:

strategy:
matrix:
os:
- "ubuntu:20.04"
- "ubuntu:22.04"

runs-on: ubuntu-latest
container:
image: "${{ matrix.os }}"

steps:

- name: Check out code
uses: actions/checkout@v3

- name: Prepare Docker
run: ./scripts/prepare_docker.bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install direnv
shell: su norm --command "bash --login {0}"
run: programs/direnv/install.bash

- name: Install direnv again (test idempotency)
shell: su norm --command "bash --login {0}"
run: programs/direnv/install.bash

35 changes: 35 additions & 0 deletions programs/direnv/install.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# Name: direnv
# https://github.com/direnv/direnv

set -euxo pipefail

cd "$(mktemp --dir)"

sudo apt-get update

sudo apt-get --assume-yes install \
curl \
jq

browser_download_url=$(
curl -Ss 'https://api.github.com/repos/direnv/direnv/releases/latest' |
jq -r '.assets[] | select(.name == "direnv.linux-amd64") | .browser_download_url'
)

download_filename=$(
curl \
--silent \
--show-error \
--url "$browser_download_url" \
--location \
--remote-name \
--write-out '%{filename_effective}'
)

chmod +x "${download_filename}"

sudo mv "${download_filename}" /usr/local/bin/direnv

direnv --version

0 comments on commit 5379566

Please sign in to comment.