avoid downloading dagger if requested version is already installed (#187)

* avoid overwriting existing dagger install unless force-install is true

Signed-off-by: kpenfound <kyle@dagger.io>

* add force-install to version tests

Signed-off-by: kpenfound <kyle@dagger.io>

* only skip install if we requested the same version that we already had

Signed-off-by: kpenfound <kyle@dagger.io>

* fix dagger check logic

Signed-off-by: kpenfound <kyle@dagger.io>

* remove incorrect and unused default for engine-stop

Signed-off-by: kpenfound <kyle@dagger.io>

* add tests for commit and latest

Signed-off-by: kpenfound <kyle@dagger.io>

* wrong commit in commit test

Signed-off-by: kpenfound <kyle@dagger.io>

---------

Signed-off-by: kpenfound <kyle@dagger.io>
This commit is contained in:
Kyle Penfound 2025-09-22 12:04:05 -04:00 committed by GitHub
parent 055bb3b2af
commit d913e70051
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 17 deletions

View file

@ -2,8 +2,9 @@ name: "Dagger for GitHub"
description: "Run dagger commands in Github Actions"
inputs:
version:
description: "Dagger Version"
required: true
description: "Dagger Version. Use semver vX.Y.Z or 'latest'"
required: false
default: "latest"
commit:
description: "Dagger Dev Commit"
required: false
@ -72,12 +73,25 @@ runs:
if [[ "$VERSION" == "latest" ]]; then
VERSION=
fi
latest=$(curl https://dl.dagger.io/dagger/versions/latest)
COMMIT=${{ inputs.commit }}
# The install.sh script creates path ${prefix_dir}/bin
curl -fsS https://dl.dagger.io/dagger/install.sh \
| BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
if [[ -x "$(command -v dagger)" ]]; then
echo "::group::Checking dagger"
version="$(dagger --silent version | cut --fields 2 --delimiter ' ')"
echo "Found existing dagger version: $version"
if [[ "$version" == "$VERSION" ]] || [[ "$version" == "$latest" ]]; then
echo "dagger ${version} is already installed, skipping installation"
exit 0
fi
echo "::endgroup::"
fi
echo "::group::Installing dagger"
curl -fsSL https://dl.dagger.io/dagger/install.sh | \
BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
echo "::endgroup::"
- id: assemble
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''