Skip to content

Commit e590375

Browse files
committed
Add ability to change workspace directory
1 parent 9a1a639 commit e590375

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

action.sh

+27-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/bin/bash
2-
set -e
32
export FVM_VERSION=${1:-"latest"}
3+
export FVM_WORKSPACE=${$2:-"${GITHUB_WORKSPACE}"}
44
export FVM_CACHE_PATH="${RUNNER_TEMP}/fvm_cache"
55
export FVM_GIT_CACHE_PATH="${RUNNER_TEMP}/fvm_git_cache"
6-
7-
FLUTTER_PUB_CACHE="${RUNNER_TEMP}/flutter/pub-cache"
6+
export FLUTTER_PUB_CACHE="${RUNNER_TEMP}/flutter/pub-cache"
87

98
echo "::group::Installing FVM version ${FVM_VERSION}"
109
source "${GITHUB_ACTION_PATH}/hacks/install.sh"
@@ -14,20 +13,29 @@ echo "::endgroup::"
1413
echo "PUB_CACHE=${FLUTTER_PUB_CACHE}" >> $GITHUB_ENV
1514
mkdir -p $FLUTTER_PUB_CACHE
1615

17-
echo "::group::Setting up FVM environment"
18-
echo -e "yes\nyes\n" | fvm install
19-
20-
# Invoke Flutter SDK to suppress the analytics.
21-
fvm flutter --version --suppress-analytics 2>&1 >/dev/null
22-
23-
# Disable Google Analytics and CLI animations
24-
fvm flutter config --no-analytics 2>&1 >/dev/null
25-
fvm flutter config --no-cli-animations 2>&1 >/dev/null
26-
27-
# Report success, and print version.
28-
echo "Succesfully installed Flutter SDK:"
29-
echo "------------------------------------------------------------------------------"
30-
fvm dart --version
31-
fvm flutter --version
32-
16+
echo "::group::Setting up FVM workspace"
17+
if cd ${FVM_WORKSPACE}; then
18+
echo "Changed workspace directory to ${FVM_WORKSPACE}"
19+
else
20+
echo "Failed to change workspace directory to ${FVM_WORKSPACE}"
21+
exit 1
22+
fi
23+
24+
if [ -f ".fvmrc" ]; then
25+
echo "Detected .fvmrc file, using it to install Flutter SDK"
26+
echo -e "yes\nyes\n" | fvm install
27+
28+
# Invoke Flutter SDK to suppress the analytics.
29+
fvm flutter --version --suppress-analytics 2>&1 >/dev/null
30+
31+
# Disable Google Analytics and CLI animations
32+
fvm flutter config --no-analytics 2>&1 >/dev/null
33+
fvm flutter config --no-cli-animations 2>&1 >/dev/null
34+
35+
# Report success, and print version.
36+
echo "Succesfully installed Flutter SDK:"
37+
echo "------------------------------------------------------------------------------"
38+
fvm dart --version
39+
fvm flutter --version
40+
fi
3341
echo "::endgroup::"

action.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
description: "The version to install: Default: latest"
99
required: false
1010
default: "latest"
11+
workspace:
12+
description: "The working directory to run the action in"
13+
required: false
14+
default: "{{ github.workspace }}"
1115
runs:
1216
using: "composite"
1317
steps:
@@ -16,4 +20,4 @@ runs:
1620
shell: bash
1721
env:
1822
GITHUB_TOKEN: ${{ github.token }}
19-
run: $GITHUB_ACTION_PATH/action.sh ${{ inputs.version }}
23+
run: $GITHUB_ACTION_PATH/action.sh ${{ inputs.version }} ${{ inputs.workspace }}

0 commit comments

Comments
 (0)