-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
50 lines (45 loc) · 1.68 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: tfswitch
author: Stephen Attard
description: Setup tfswitch to install a specific version of terraform
outputs:
terraform_version:
description: "The installed version of terraform"
value: ${{ steps.tfswitch-install.outputs.terraform_version }}
runs:
using: composite
steps:
- name: Check Runner OS
if: ${{ runner.os != 'Linux' }}
shell: bash
run: |
echo "::error title=⛔ error hint::This action is only supported on Linux Runners"
exit 1
- name: Install tfswitch
shell: bash
id: tfswitch-install
run: |
echo "Downloading install script .."
curl -sLo install.sh https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh
echo "Configuring install script to be executable .."
chmod 755 install.sh
echo "Creating $HOME/.bin for tfswitch binary .."
mkdir -p $HOME/.bin
echo "Installing tfswitch version .."
./install.sh -b $HOME/.bin
echo "Running tfswitch from $HOME/.bin .."
$HOME/.bin/tfswitch --version
export PATH=$PATH:$HOME/.bin
echo "Running tfswitch assuming PATH is set .."
tfswitch --version
echo "Exporting PATH to GITHUB_PATH .."
echo $HOME/.bin >> $GITHUB_PATH
echo "Exporting terraform version to GITHUB_OUTPUT as terraform_version.."
echo "terraform_version=$(terraform --version -json | jq -r .terraform_version)" >> "$GITHUB_OUTPUT"
if [ -e "/usr/local/bin/terraform" ]; then
echo "Unlinking default version of terraform .."
unlink /usr/local/bin/terraform
fi
echo "Done!"
branding:
color: blue
icon: box