Skip to content

Commit

Permalink
Install fzf
Browse files Browse the repository at this point in the history
  • Loading branch information
iainelder committed Jul 7, 2023
1 parent 96c4a0f commit acea9da
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/fzf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: fzf
on:
push:
paths:
- programs/fzf/install.bash
- .github/workflows/fzf.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 fzf
shell: su norm --command "bash --login {0}"
run: programs/fzf/install.bash

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

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

# Name: fzf
# https://github.com/junegunn/fzf

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/junegunn/fzf/releases/latest' |
jq -r '.assets[] | select(.name | test("fzf-.*?-linux_amd64.tar.gz")) | .browser_download_url'
)

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

chmod +x "${download_filename}"

tar --extract --gzip --file "$download_filename"

sudo mv fzf /usr/local/bin/fzf

fzf --version

0 comments on commit acea9da

Please sign in to comment.