Skip to content

Commit

Permalink
Add an action to install these build scripts. (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Thorogood committed Sep 1, 2021
1 parent 4cf1d11 commit c35fa4a
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test-install-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Test actions/install
on:
push:
branches:
- test-install-action

jobs:
test-install-action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: ./actions/install/entrypoint.sh
- run: test -d ./.build-scripts/sources
18 changes: 18 additions & 0 deletions actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Install uwit-iam/common-build-scripts
description: >
Installs the common-build-scripts into the github workspace in the
`./build-scripts` directory.
inputs:
version:
required: true
default: latest
description: >
Supply the version you'd like to install; default is 'latest'.
Only versions 0.1.1 or greater are supported.
runs:
using: composite
steps:
- shell: bash
run: ${{ github.action_path }}/entrypoint.sh
60 changes: 60 additions & 0 deletions actions/install/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash

ARG_VERSION_DEFAULT=latest

function print_help {
cat <<EOF
Use: entrypoint.sh -v 0.1.5 [--debug --help]
Options:
-v, --version The version to install (default: $ARG_VERSION_DEFAULT)
-h, --help Show this message and exit
-g, --debug Show commands as they are executing
EOF
}

while (( $# ))
do
case $1 in
--version|-v)
shift
ARG_VERSION=$1
;;
--help|-h)
print_help
exit 0
;;
--debug|-g)
set -x
;;
*)
echo "Invalid Option: $1"
print_help
exit 1
;;
esac
shift
done

ARG_VERSION=${ARG_VERSION:-$ARG_VERSION_DEFAULT}

function get_release_commit {
local release="$1"
local url_path="$release"
if [[ "$release" != 'latest' ]]
then
url_path="tags/$release"
fi
local url="https://api.github.com/repos/uwit-iam/common-build-scripts/releases/${url_path}"
local commit=$(curl -s $url | jq '.target_commitish' | sed 's|"||g')
echo "$commit"
}

function get_install_script_url {
local commit="$1"
echo "https://raw.githubusercontent.com/UWIT-IAM/common-build-scripts/${commit}/scripts/install-common-build-scripts.sh"
}

commit=$(get_release_commit $ARG_VERSION)
url=$(get_install_script_url $commit)
export BUILD_SCRIPTS_DIR="./.build-scripts"
bash <(curl -Lsk ${url})

0 comments on commit c35fa4a

Please sign in to comment.