# Use FuzzyShare from CI

A CI job needs three things: the server's address, a key, and a command. The key should belong to the job alone.

## Create a key for CI

```sh
fuzzy keys add ci-bot
```

The key is printed once. Store it as a secret in your CI system, for example `FUZZY_KEY`. Store the address as `FUZZY_URL`. When the job leaks or is retired, revoke only that key:

```sh
fuzzy keys rm k_37ea501438da
```

## Install the CLI in the job

```sh
curl -fsSL https://fuzzyshare.com/install.sh | FUZZY_INSTALL_DIR="$HOME/.local/bin" sh
export PATH="$HOME/.local/bin:$PATH"
```

## Upload

With `FUZZY_URL` and `FUZZY_KEY` set, no `fuzzy login` is needed:

```sh
fuzzy put dist/app.tar.gz --ttl 3d --share
```

The URL is the only thing printed on standard output, so you can capture it:

```sh
URL=$(fuzzy put dist/app.tar.gz --ttl 3d --share)
echo "Artifact: $URL"
```

## GitHub Actions

```yaml
- name: Upload build
  env:
    FUZZY_URL: ${{ vars.FUZZY_URL }}
    FUZZY_KEY: ${{ secrets.FUZZY_KEY }}
  run: |
    curl -fsSL "$FUZZY_URL/install.sh" | FUZZY_INSTALL_DIR="$HOME/.local/bin" sh
    echo "$HOME/.local/bin" >> "$GITHUB_PATH"
    "$HOME/.local/bin/fuzzy" put dist/app.tar.gz --ttl 3d --share
```

## Without the CLI

```sh
curl -fsS -H "Authorization: Bearer $FUZZY_KEY" \
  -T dist/app.tar.gz "$FUZZY_URL/files/app.tar.gz?ttl=3d&visibility=public"
```

The response includes `public_url` and `raw_url`.

> [!TIP]
> Pick the shortest `--ttl` that covers the job's consumers. Artifacts that clean themselves up cannot pile up.

Exit codes and more patterns are in [Scripting and exit codes](cli-scripting.md).
