Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 26, 2025

The docs workflow fails when re-running on the same tag because mike deploy errors with "alias 'latest' already exists for version X".

Changes

  • Add --update-aliases flag to mike deploy command to allow updating existing aliases
- name: build docs
  run: mike deploy --push --update-aliases ${GITHUB_REF#refs/tags/} latest

This flag allows mike to update aliases that already exist, making the command idempotent without needing error handling.

Fixes failing run: https://github.com/USTC-KnowledgeComputingLab/ds/actions/runs/19689926624/job/56403396937

Original prompt

The GitHub Actions docs job (job id 56403396937) is failing with the error:

error: alias 'latest' already exists for version 'v0.0.2-alpha3'

This happens in .github/workflows/docs.yml when mike deploy --push ${GITHUB_REF#refs/tags/} latest attempts to create the 'latest' alias but mike returns an error if that alias already exists for the same version. The failing run: https://github.com/USTC-KnowledgeComputingLab/ds/actions/runs/19689926624/job/56403396937 (ref: 19192b8).

Make the docs workflow idempotent: update .github/workflows/docs.yml to capture the output of mike deploy and treat the specific "alias 'latest' already exists" error as non-fatal while still failing on other errors. This prevents the job from failing when re-deploying the same version.

Change details (edit file .github/workflows/docs.yml at ref 19192b8): replace the current "build docs" and "set default" steps with the following steps that run a safe deploy script:

- name: build docs
  run: |
    set -e
    VERSION=${GITHUB_REF#refs/tags/}
    TMP_OUT=$(mktemp)
    if mike deploy --push "$VERSION" latest >"$TMP_OUT" 2>&1; then
      echo "mike deploy succeeded"
    else
      if grep -q "alias 'latest' already exists" "$TMP_OUT"; then
        echo "alias 'latest' already exists for this version; continuing"
      else
        cat "$TMP_OUT"
        exit 1
      fi
    fi

- name: set default
  run: mike set-default --push latest

Notes:

  • This change prevents the job from failing when mike reports the existing-alias error while still surfacing other errors.
  • I referenced the failing job id 56403396937 and commit ref 19192b8 in the problem statement.

Please create a pull request with this change, updating .github/workflows/docs.yml accordingly.

This pull request was created as a result of the following prompt from Copilot chat.

The GitHub Actions docs job (job id 56403396937) is failing with the error:

error: alias 'latest' already exists for version 'v0.0.2-alpha3'

This happens in .github/workflows/docs.yml when mike deploy --push ${GITHUB_REF#refs/tags/} latest attempts to create the 'latest' alias but mike returns an error if that alias already exists for the same version. The failing run: https://github.com/USTC-KnowledgeComputingLab/ds/actions/runs/19689926624/job/56403396937 (ref: 19192b8).

Make the docs workflow idempotent: update .github/workflows/docs.yml to capture the output of mike deploy and treat the specific "alias 'latest' already exists" error as non-fatal while still failing on other errors. This prevents the job from failing when re-deploying the same version.

Change details (edit file .github/workflows/docs.yml at ref 19192b8): replace the current "build docs" and "set default" steps with the following steps that run a safe deploy script:

- name: build docs
  run: |
    set -e
    VERSION=${GITHUB_REF#refs/tags/}
    TMP_OUT=$(mktemp)
    if mike deploy --push "$VERSION" latest >"$TMP_OUT" 2>&1; then
      echo "mike deploy succeeded"
    else
      if grep -q "alias 'latest' already exists" "$TMP_OUT"; then
        echo "alias 'latest' already exists for this version; continuing"
      else
        cat "$TMP_OUT"
        exit 1
      fi
    fi

- name: set default
  run: mike set-default --push latest

Notes:

  • This change prevents the job from failing when mike reports the existing-alias error while still surfacing other errors.
  • I referenced the failing job id 56403396937 and commit ref 19192b8 in the problem statement.

Please create a pull request with this change, updating .github/workflows/docs.yml accordingly.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
@hzhangxyz hzhangxyz marked this pull request as ready for review November 26, 2025 02:16
Copilot AI changed the title [WIP] Update docs workflow to handle existing alias error Make docs workflow idempotent by handling existing alias error Nov 26, 2025
Copilot AI requested a review from hzhangxyz November 26, 2025 02:17
Copy link
Member

@hzhangxyz hzhangxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你看看这个:

mike deploy [version] [alias]...

If [version] already exists, this command will also update all of the pre-existing aliases for it. Normally, if an alias specified on the command line is already associated with another version, this will return an error. If you do want to move an alias from another version to this version (including when the new version itself was previously an alias), you can pass -u/--update-aliases to allow this. For example, this can be useful when releasing a new version and updating the latest alias to point to this new version.

似乎在原本的基础上,加个参数就行了

Co-authored-by: hzhangxyz <11623447+hzhangxyz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 26, 2025

你看看这个:

mike deploy [version] [alias]......

You're right! Updated to use --update-aliases flag - much simpler. See commit 9206908.

Copilot AI changed the title Make docs workflow idempotent by handling existing alias error Make docs workflow idempotent by using --update-aliases flag Nov 26, 2025
Copilot AI requested a review from hzhangxyz November 26, 2025 02:23
@hzhangxyz hzhangxyz merged commit 5f6a324 into main Nov 26, 2025
64 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants