Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add install action to install all trunk tools in trunk.yaml #234

Merged
merged 11 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions install/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Trunk Check
author: trunk.io
description: Install trunk and managed tools to PATH

inputs:
tools:
description: specific tools to install (if not specified will install all enabled tools)
required: false

branding:
icon: check
color: green

runs:
using: composite
steps:
- name: get trunk
shell: bash
run: ${GITHUB_ACTION_PATH}/get_trunk.sh

- name: clean up possible dead symlink
shell: bash
run: |
tools_path=".trunk/tools"
if [ -L "${tools_path}" ] && [ ! -e "${tools_path}" ] ; then
rm "${tools_path}"
fi

- name: Trunk install
shell: bash
run: trunk tools install --ci ${{ inputs.tools }}

- name: Add .trunk/tools to path
shell: bash
run: echo ".trunk/tools" >> $GITHUB_PATH
20 changes: 20 additions & 0 deletions install/get_trunk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -euo pipefail

if [[ ${INPUT_DEBUG:-false} == "true" ]]; then
set -x
fi

tmpdir="$(mktemp -d)"
echo "TRUNK_TMPDIR=${tmpdir}" >>"${GITHUB_ENV}"

curl -fsSL https://trunk.io/releases/trunk -o "${tmpdir}/trunk"
chmod u+x "${tmpdir}/trunk"
trunk_path="${tmpdir}/trunk"

echo "TRUNK_PATH=${trunk_path}" >>"${GITHUB_ENV}"
echo "${tmpdir}" >>"${GITHUB_PATH}"

# Ensure that trunk CLI is downloaded before subsequent steps (swallow output of version command)
(${trunk_path} version >/dev/null 2>&1) || echo "::warning::${trunk_path} does not exist!"
Loading