mirror of
https://github.com/dagger/dagger-for-github.git
synced 2026-01-02 05:19:47 +11:00
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:
parent
055bb3b2af
commit
d913e70051
3 changed files with 94 additions and 17 deletions
63
.github/workflows/test.yml
vendored
63
.github/workflows/test.yml
vendored
|
|
@ -248,3 +248,66 @@ jobs:
|
||||||
- name: "Test Install"
|
- name: "Test Install"
|
||||||
run: |
|
run: |
|
||||||
dagger core version
|
dagger core version
|
||||||
|
|
||||||
|
existing-install:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: "preinstall dagger"
|
||||||
|
run: |
|
||||||
|
curl -fsS https://dl.dagger.io/dagger/install.sh \
|
||||||
|
| BIN_DIR=/usr/local/bin DAGGER_VERSION="v0.18.17" sh
|
||||||
|
- name: "Install with version"
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: "v0.18.16"
|
||||||
|
- name: "Test Install"
|
||||||
|
run: |
|
||||||
|
if [[ "$(dagger core version)" == "v0.18.16" ]]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Existing install was not overridden"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
commit-install:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: "preinstall dagger"
|
||||||
|
run: |
|
||||||
|
curl -fsS https://dl.dagger.io/dagger/install.sh \
|
||||||
|
| BIN_DIR=/usr/local/bin DAGGER_VERSION="v0.18.17" sh
|
||||||
|
- name: "Install with version"
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
commit: "71f2e104b045ddc3b0cc611b81370707bf21bc27"
|
||||||
|
- name: "Test Install"
|
||||||
|
run: |
|
||||||
|
if [[ "$(dagger version)" == *"v0.18.19-250918123923-71f2e104b045"* ]]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Existing install was not overridden"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
latest-install:
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: "preinstall dagger"
|
||||||
|
run: |
|
||||||
|
curl -fsS https://dl.dagger.io/dagger/install.sh \
|
||||||
|
| BIN_DIR=/usr/local/bin DAGGER_VERSION="v0.18.17" sh
|
||||||
|
- name: "Install with version"
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
- name: "Test Install"
|
||||||
|
run: |
|
||||||
|
if [[ "$(dagger version)" != "v0.18.17" ]]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Existing install was not overridden with latest"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ By setting the version to `latest`, this action will install the latest version
|
||||||
### All `with:` input parameter options
|
### All `with:` input parameter options
|
||||||
|
|
||||||
| Key | Description | Required | Default |
|
| Key | Description | Required | Default |
|
||||||
| -------------- | ----------------------------------------------------------- | -------- | ------------------ |
|
| --------------- | ----------------------------------------------------------------- | -------- | ------------------ |
|
||||||
| `version` | Dagger Version | true | n/a use semver x.y.z or 'latest'
|
| `version` | Dagger Version. Use semver vX.Y.Z or 'latest' | true | 'latest' |
|
||||||
| `commit` | Dagger Dev Commit (overrides `version`) | false | '' |
|
| `commit` | Dagger Dev Commit (overrides `version`) | false | '' |
|
||||||
| `dagger-flags` | Dagger CLI Flags | false | '--progress plain' |
|
| `dagger-flags` | Dagger CLI Flags | false | '--progress plain' |
|
||||||
| `verb` | CLI verb (call, run, download, up, functions, shell, query) | false | 'call' |
|
| `verb` | CLI verb (call, run, download, up, functions, shell, query) | false | 'call' |
|
||||||
|
|
|
||||||
24
action.yml
24
action.yml
|
|
@ -2,8 +2,9 @@ name: "Dagger for GitHub"
|
||||||
description: "Run dagger commands in Github Actions"
|
description: "Run dagger commands in Github Actions"
|
||||||
inputs:
|
inputs:
|
||||||
version:
|
version:
|
||||||
description: "Dagger Version"
|
description: "Dagger Version. Use semver vX.Y.Z or 'latest'"
|
||||||
required: true
|
required: false
|
||||||
|
default: "latest"
|
||||||
commit:
|
commit:
|
||||||
description: "Dagger Dev Commit"
|
description: "Dagger Dev Commit"
|
||||||
required: false
|
required: false
|
||||||
|
|
@ -72,12 +73,25 @@ runs:
|
||||||
if [[ "$VERSION" == "latest" ]]; then
|
if [[ "$VERSION" == "latest" ]]; then
|
||||||
VERSION=
|
VERSION=
|
||||||
fi
|
fi
|
||||||
|
latest=$(curl https://dl.dagger.io/dagger/versions/latest)
|
||||||
|
|
||||||
COMMIT=${{ inputs.commit }}
|
COMMIT=${{ inputs.commit }}
|
||||||
|
|
||||||
# The install.sh script creates path ${prefix_dir}/bin
|
if [[ -x "$(command -v dagger)" ]]; then
|
||||||
curl -fsS https://dl.dagger.io/dagger/install.sh \
|
echo "::group::Checking dagger"
|
||||||
| BIN_DIR=${prefix_dir}/bin DAGGER_VERSION="$VERSION" DAGGER_COMMIT="$COMMIT" sh
|
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
|
- id: assemble
|
||||||
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''
|
if: inputs.call != '' || inputs.shell != '' || inputs.args != ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue