mirror of
https://github.com/dagger/dagger-for-github.git
synced 2025-12-31 20:59:43 +11:00
* fix(ux): increase readability of install step The official github self-hosted action container does not include curl in the OS but because the `curl` command in the GH Action's install step redirects stderr to /dev/null, it was hard to determine that. As part of my Dagger interview, @gerhard and I investigated and found that issue. We changed the `curl` flags from `-sL` to `-fsS` to be more verbose with the error reporting and remove following redirects, as the move to Cloudfront obviated the need for that flag. We also removed the subshell in the install step at the end because it was not needed and introduced extra complexity. I could also see checking for the presence of curl at the beginning of the script and failing quickly with a message, but that was not discussed in the interview. Given that this happens very quickly and solves for other HTTP errors it doesn't seem particularly necessary but I could see the potential for it, if the desire for it was there. Signed-off-by: Josh Ghiloni <ghiloni@gmail.com> * Use pipefail when we pipe commands Use clearer syntax with pipes (functional style similar to Elixir). Make the shell & if / env obvious in the commands by declaring them first in the step. Signed-off-by: Gerhard Lazu <gerhard@dagger.io> --------- Signed-off-by: Josh Ghiloni <ghiloni@gmail.com> Signed-off-by: Gerhard Lazu <gerhard@dagger.io> Co-authored-by: Gerhard Lazu <gerhard@dagger.io>
80 lines
2.4 KiB
YAML
80 lines
2.4 KiB
YAML
name: "Dagger for GitHub"
|
|
description: "Run dagger commands in Github Actions"
|
|
inputs:
|
|
version:
|
|
description: "Dagger Version"
|
|
required: false
|
|
default: "0.12.0"
|
|
dagger-flags:
|
|
description: "Dagger CLI Flags"
|
|
required: false
|
|
default: "--progress plain"
|
|
verb:
|
|
description: "CLI verb (call, run, download, up, functions, shell, query)"
|
|
required: false
|
|
default: "call"
|
|
workdir:
|
|
description: "The working directory in which to run the Dagger CLI"
|
|
required: false
|
|
default: "."
|
|
cloud-token:
|
|
description: "Dagger Cloud Token"
|
|
required: false
|
|
default: ""
|
|
module:
|
|
description: "Dagger module to call. Local or Git"
|
|
required: false
|
|
default: ""
|
|
args:
|
|
description: "Arguments to pass to CLI"
|
|
required: false
|
|
default: ""
|
|
engine-stop:
|
|
description: "Whether to stop the Dagger Engine after this run"
|
|
required: false
|
|
default: "true"
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- shell: bash
|
|
run: |
|
|
set -o pipefail
|
|
# Fallback to /usr/local for backwards compatability
|
|
prefix_dir="${RUNNER_TEMP:-/usr/local}"
|
|
# Ensure the dir is writable otherwise fallback to tmpdir
|
|
if [[ ! -d "$prefix_dir" ]] || [[ ! -w "$prefix_dir" ]]; then
|
|
prefix_dir="$(mktemp -d)"
|
|
fi
|
|
printf '%s/bin' "$prefix_dir" >> $GITHUB_PATH
|
|
|
|
# If the dagger version is 'latest', set the version back to an empty
|
|
# string. This allows the install script to detect and install the latest
|
|
# version itself
|
|
VERSION=${{ inputs.version }}
|
|
if [[ "$VERSION" == "latest" ]]; then
|
|
VERSION=
|
|
fi
|
|
|
|
# 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 sh
|
|
|
|
- shell: bash
|
|
env:
|
|
INPUT_MODULE: ${{ inputs.module }}
|
|
run: |
|
|
cd ${{ inputs.workdir }} && { \
|
|
DAGGER_CLOUD_TOKEN=${{ inputs.cloud-token }} \
|
|
dagger \
|
|
${{ inputs.dagger-flags }} \
|
|
${{ inputs.verb }} \
|
|
${INPUT_MODULE:+-m $INPUT_MODULE} \
|
|
${{ inputs.args }}; }
|
|
|
|
- if: inputs.engine-stop == 'true'
|
|
shell: bash
|
|
run: |
|
|
mapfile -t containers < <(docker ps --filter name="dagger-engine-*" -q)
|
|
if [[ "${#containers[@]}" -gt 0 ]]; then
|
|
docker stop -t 300 "${containers[@]}";
|
|
fi
|