diff --git a/truenas-deploy/README.md b/truenas-deploy/README.md index 17df704..ad0ae32 100644 --- a/truenas-deploy/README.md +++ b/truenas-deploy/README.md @@ -1,23 +1,23 @@ -# Deploy to TrueNAS (`truenas-deploy`) +# TrueNAS Deploy -Deploys a Docker Compose stack directly to TrueNAS SCALE (`/mnt/jupiter/apps/`) over SSH and runs `docker compose pull && docker compose up -d --remove-orphans`. +Composite Gitea Action that deploys a Docker Compose stack to TrueNAS SCALE over SSH (`/mnt/jupiter/apps//`) and pulls the latest container images. -## Usage +## Inputs + +| Name | Required | Default | Description | +| :--- | :---: | :---: | :--- | +| `ssh_key` | Yes | - | Private SSH key for authenticating to TrueNAS (`secrets.TRUENAS_SSH_KEY`) | +| `app_name` | No | `${{ github.repository }}` | Application subpath under `/mnt/jupiter/apps//` (defaults to `/`) | +| `compose_file` | No | `docker-compose.yaml` | Path to the local compose file (`docker-compose.yaml` or `docker-compose.yml` auto-detected) | +| `host` | No | `10.0.0.218` | TrueNAS SSH host IP or domain | +| `user` | No | `root` | TrueNAS SSH user | +| `env_file_content` | No | `""` | Optional `.env` file content to write to `/mnt/jupiter/apps///.env` (`0600`) | + +## Example Usage ```yaml -- name: Deploy to TrueNAS - uses: https://git.rodydavis.dev/rodydavis/shared-actions/truenas-deploy@main - with: - ssh_key: ${{ secrets.TRUENAS_SSH_KEY }} + - name: Deploy to TrueNAS + uses: https://git.rodydavis.dev/rodydavis/shared-actions/truenas-deploy@main + with: + ssh_key: ${{ secrets.TRUENAS_SSH_KEY }} ``` - -### Optional Inputs - -| Input | Description | Default | -| :--- | :--- | :--- | -| `ssh_key` | **(Required)** Private SSH key for authenticating to TrueNAS (`secrets.TRUENAS_SSH_KEY`). | — | -| `app_name` | Application directory name under `/mnt/jupiter/apps/`. | Repository name | -| `compose_file` | Local compose file path (auto-detects `docker-compose.yaml` or `docker-compose.yml`). | `docker-compose.yaml` | -| `host` | TrueNAS SSH host IP or hostname. | `10.0.0.218` | -| `user` | TrueNAS SSH user. | `root` | -| `env_file_content` | Optional `.env` file contents to write to `/mnt/jupiter/apps//.env`. | `''` | diff --git a/truenas-deploy/action.yml b/truenas-deploy/action.yml index 2f8013c..88eb9c3 100644 --- a/truenas-deploy/action.yml +++ b/truenas-deploy/action.yml @@ -5,7 +5,7 @@ inputs: description: 'Private SSH key for authenticating to TrueNAS' required: true app_name: - description: 'Application directory name under /mnt/jupiter/apps/ (defaults to repository name)' + description: 'Application subpath under /mnt/jupiter/apps// (defaults to /)' required: false default: '' compose_file: @@ -37,13 +37,21 @@ runs: INPUT_HOST: ${{ inputs.host }} INPUT_USER: ${{ inputs.user }} INPUT_ENV_CONTENT: ${{ inputs.env_file_content }} - REPO_NAME: ${{ github.event.repository.name }} + REPO_FULL_NAME: ${{ github.repository }} + REPO_OWNER: ${{ github.repository_owner }} run: | set -euo pipefail - APP_DIR_NAME="${INPUT_APP_NAME:-$REPO_NAME}" - if [ -z "$APP_DIR_NAME" ]; then - APP_DIR_NAME=$(basename "$GITHUB_REPOSITORY") + FULL_REPO="${REPO_FULL_NAME:-$GITHUB_REPOSITORY}" + OWNER="${REPO_OWNER:-$(dirname "$FULL_REPO")}" + + if [ -n "$INPUT_APP_NAME" ]; then + case "$INPUT_APP_NAME" in + */*) APP_DIR_NAME="$INPUT_APP_NAME" ;; + *) APP_DIR_NAME="${OWNER}/${INPUT_APP_NAME}" ;; + esac + else + APP_DIR_NAME="$FULL_REPO" fi COMPOSE_FILE="$INPUT_COMPOSE_FILE"