From 04bbe39a89fbd580c6d8aeaf36c6fed71238d476 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Wed, 28 Feb 2024 11:21:53 -0500 Subject: [PATCH] Add actionlint feature --- src/actionlint/devcontainer-feature.json | 23 ++++++++++++++++++++ src/actionlint/install.sh | 27 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/actionlint/devcontainer-feature.json create mode 100755 src/actionlint/install.sh diff --git a/src/actionlint/devcontainer-feature.json b/src/actionlint/devcontainer-feature.json new file mode 100644 index 0000000..103f072 --- /dev/null +++ b/src/actionlint/devcontainer-feature.json @@ -0,0 +1,23 @@ +{ + "name": "actionlint", + "id": "actionlint", + "version": "1.0.0", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest" + ], + "default": "latest", + "description": "Select or enter an actionlint version." + }, + "installPath": { + "type": "string", + "default": "/usr/local/bin", + "description": "The path where actionlint will be installed." + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils" + ] +} diff --git a/src/actionlint/install.sh b/src/actionlint/install.sh new file mode 100755 index 0000000..96566ab --- /dev/null +++ b/src/actionlint/install.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env sh + +set -e + +ACTIONLINT_VERSION="${VERSION:-"latest"}" +INSTALL_PATH="${INSTALLPATH:-"/usr/local/bin"}" + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +curl_installed="" + +if ! [ type curl >/dev/null 2>&1 ]; then + apt update --yes + apt install --no-install-recommends --yes curl ca-certificates + + curl_installed="true" +fi + +curl -sSL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash | \ + /bin/bash -s -- "${ACTIONLINT_VERSION}" "${INSTALL_PATH}" + +if ! [ -z $curl_installed ]; then + apt purge curl --autoremove --yes +fi