# Docs Alias Failure Notification workflow (vercel/turbo)

> The Docs Alias Failure Notification workflow from vercel/turbo, explained and optimized by Latchkey.

Source: https://latchkey.dev/workflows/vercel-turbo-docs-alias-failure-notification  
Upstream: [vercel/turbo](https://github.com/vercel/turbo/blob/main/.github/workflows/docs-alias-failure-notification.yml) (.github/workflows/docs-alias-failure-notification.yml), licence MIT

## What it does

This is the Docs Alias Failure Notification workflow from the vercel/turbo repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

## The workflow

```yaml
# Docs Alias Failure Notification
#
# Sends a Slack notification when the versioned docs alias assignment fails.

name: Docs Alias Failure Notification

env:
  TURBO_TELEMETRY_MESSAGE_DISABLED: "1"

on:
  workflow_run:
    workflows: ["Release"]
    types:
      - completed

permissions:
  contents: read

jobs:
  notify-failure:
    name: "Notify Slack on Docs Alias Failure"
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'failure' }}
    steps:
      # Fetch version.txt via the API at the exact commit of the failed run
      # instead of checking out the branch. This avoids checking out a ref by
      # name (the staging branch may already be deleted by the failure cleanup
      # job) and avoids putting any repo content on disk.
      - name: Get version
        id: version
        shell: bash
        env:
          GH_TOKEN: ${{ github.token }}
          HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
        run: |
          if CONTENT=$(gh api -H "Accept: application/vnd.github.raw+json" "repos/${{ github.repository }}/contents/version.txt?ref=${HEAD_SHA}"); then
            IFS= read -r VERSION <<< "$CONTENT"
            if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]]; then
              printf 'version=%s\n' "$VERSION" >> "$GITHUB_OUTPUT"
            else
              echo "::warning::version.txt did not contain a valid release version. Reporting unknown version."
              echo "version=unknown" >> "$GITHUB_OUTPUT"
            fi
          else
            echo "::warning::Could not fetch version.txt at ${HEAD_SHA}. Reporting unknown version."
            echo "version=unknown" >> "$GITHUB_OUTPUT"
          fi

      - name: Send failure notification to Slack
        uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0
        with:
          webhook: ${{ secrets.DOCS_ALIAS_FAILURE_SLACK_WEBHOOK_URL }}
          webhook-type: incoming-webhook
          payload: |
            {
              "version": ${{ toJSON(steps.version.outputs.version) }}
            }
```

## FAQ

### What does the Docs Alias Failure Notification workflow (vercel/turbo) workflow do?

This is the Docs Alias Failure Notification workflow from the vercel/turbo repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

### What CI health grade does this workflow get?

This Automation and other workflow grades A. Paste your own workflow into the Latchkey grader to see its grade and the exact fixes.

### How can I improve this Automation and other workflow?

Add job timeouts. Latchkey applies these automatically on managed runners when you point runs-on at Latchkey.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
