Skip to content

clever link fails when app is already linked (re-deploy scenario) #222

@guillaumebadin

Description

@guillaumebadin

Summary

The action fails with exit code 1 when attempting to link an app that is already linked, even though this is a valid use case for re-deployments (e.g., synchronize events on PRs).

Environment

Steps to Reproduce

  1. Create a PR that triggers the review app workflow
  2. Workflow creates and links the app successfully
  3. Push a new commit to the PR (triggers synchronize event)
  4. Workflow re-runs and attempts to link the same app
  5. Fails with: Application app_xxx is already linked with alias app_xxx

Error Log

[command]/action/node_modules/.bin/clever link app_24e00c72-7811-42a4-9fb2-e95928f2a3f6 --alias app_24e00c72-7811-42a4-9fb2-e95928f2a3f6

[ERROR] Application app_24e00c72-7811-42a4-9fb2-e95928f2a3f6 is already linked with alias app_24e00c72-7811-42a4-9fb2-e95928f2a3f6

##[error]The process '/action/node_modules/.bin/clever' failed with exit code 1

Expected Behavior

The action should handle the "already linked" case gracefully:

  • Either skip linking if already linked
  • Or unlink first, then re-link

Suggested Fix

In the action's entrypoint script, before calling clever link:

# Unlink any existing app first (ignore errors if not linked)
clever unlink --alias "$APP_ID" 2>/dev/null || true

# Then link
clever link "$APP_ID" --alias "$APP_ID"

Or check if already linked:

if ! clever link "$APP_ID" --alias "$APP_ID" 2>&1 | grep -q "already linked"; then
  # Handle actual errors
  exit 1
fi

Workaround

Replace the action with direct CLI commands:

- name: Setup Clever CLI
  run: npm install -g clever-tools

- name: Deploy Code to CleverCloud
  run: |
    clever login --token "$CLEVER_TOKEN" --secret "$CLEVER_SECRET"
    clever unlink --alias "$APP_ID" 2>/dev/null || true
    clever link "$APP_ID" --alias "$APP_ID"
    clever deploy --force --alias "$APP_ID"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions