Skip to content

add concurrency to auto-review workflow to cancel in-progress runs #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025

Conversation

catatsuy
Copy link
Owner

This pull request updates the GitHub Actions workflow for auto-review to include concurrency control, ensuring that only one instance of the workflow runs for a given pull request at a time.

Workflow improvements:

  • .github/workflows/auto-review.yml: Added a concurrency configuration to group workflows by the workflow name and reference, and to cancel any in-progress workflows for the same group.

Copy link

Automatic Review

The added concurrency block is generally a good practice to prevent overlapping runs of the same workflow on the same branch or PR, which improves efficiency and resource usage.

However, using ${{ github.ref }} as part of the concurrency group can cause unintended behavior because github.ref may contain slashes (refs/heads/feature/...), which are not allowed characters for concurrency group names and might lead to errors or incorrect grouping.

Suggestion: Sanitize or simplify the concurrency group identifier. A common pattern is to use the PR number (if available) or a sanitized version of the branch name.

Example fix using the PR number (pull requests trigger workflows and have github.event.pull_request.number):

concurrency:
  group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
  cancel-in-progress: true

If the workflow can also run on branches (not just PRs) and you want to cover both cases, you might need conditional expressions or choose one consistent identifier.

Summary:

  • Using ${{ github.ref }} directly in concurrency.group can cause failures due to invalid characters.
  • Replace it with a sanitized or simpler identifier such as PR number.

@catatsuy catatsuy merged commit a3c679e into main Apr 19, 2025
5 checks passed
@catatsuy catatsuy deleted the add-concurrency-to-auto-review-workflow branch April 19, 2025 05:27
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.

1 participant