Skip to content

Commit

Permalink
add install action to install all trunk tools in trunk.yaml (#234)
Browse files Browse the repository at this point in the history
install will pull trunk launcher from cloud into tmp location and then
run the `trunk tools install` command.

Optionally installs that are specified - else installs everything.

Example of using it in flaky factory


https://github.com/trunk-io/flake-factory/blob/main/.github/workflows/factory.yaml

      - name: trunk install
uses:
54ccfcf
  • Loading branch information
EliSchleifer committed Mar 25, 2024
1 parent 4feb07f commit 540e7fe
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
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!"

0 comments on commit 540e7fe

Please sign in to comment.