Skip to content
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

Release to branches with labels #5843

Merged
merged 4 commits into from
Jan 3, 2025
Merged

Conversation

yurisasuke
Copy link
Member

@yurisasuke yurisasuke commented Dec 23, 2024

. This github action will be triggered when a pull request is merged to master. It will then make sure check for lables in the Pr and iif there is a label in the format release-[0-9]+(.[0-9]+)?$/ it will send the comment (release to label here)

Note

  1. The label need to be created by someone in the tyk organization
  2. If it is created by someone outside the org it will not be executed

PR Type

enhancement, configuration changes


Description

  • Introduced a new GitHub Actions workflow triggered on pull request merges to master or main branches.
  • Implemented a script to process labels matching the format release-... and verify the labeler's membership in the organization.
  • Added functionality to comment on the merged pull request with a release command if the labeler is an organization member.
  • Ensured the workflow runs only when the pull request is merged.

Changes walkthrough 📝

Relevant files
Configuration changes
release-to-branches-in-label.yml
Add GitHub Actions workflow for release label handling     

.github/workflows/release-to-branches-in-label.yml

  • Added a new GitHub Actions workflow triggered on pull request merges
    to master or main.
  • Implemented a script to identify labels matching a specific format
    (release-...) and check the membership of the labeler in the
    organization.
  • Added functionality to comment on the merged pull request if the
    labeler is an organization member.
  • Configured the workflow to run only if the pull request is merged.
  • +87/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @yurisasuke yurisasuke changed the title Release to branches in label Release to branches with labels Dec 23, 2024
    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Possible Edge Case Handling

    The script skips commenting if no user is recorded for a label (line 58). This could lead to unexpected behavior if labels are added programmatically or under certain conditions. Consider adding logging or handling for such cases.

                    // If there's no recorded user (edge case), skip
                    if (!userWhoAddedLabel) continue;
    Organization Name Hardcoding

    The organization name TykTechnologies is hardcoded (line 65). This could lead to issues if the workflow is reused in other repositories or organizations. Consider making this configurable.

                        org: 'TykTechnologies',              // <--- PUT YOUR ORG NAME HERE

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add a null check for label.name to prevent runtime errors

    Validate that the label.name exists before using it in the regular expression test
    to avoid potential runtime errors.

    .github/workflows/release-to-branches-in-label.yml [55]

    -if (labelRegex.test(label.name)) {
    +if (label.name && labelRegex.test(label.name)) {
    Suggestion importance[1-10]: 9

    Why: Adding a null check for label.name is crucial to prevent potential runtime errors, especially when processing labels. This change enhances the robustness of the workflow.

    9
    General
    Make the organization name configurable to prevent hardcoding issues

    Ensure that the organization name is dynamically retrieved or clearly defined to
    avoid errors if the hardcoded value 'TykTechnologies' is incorrect or changes in the
    future.

    .github/workflows/release-to-branches-in-label.yml [65]

    -org: 'TykTechnologies',              // <--- PUT YOUR ORG NAME HERE
    +org: process.env.GITHUB_ORG || 'TykTechnologies', // Ensure the org name is dynamically retrieved or configurable
    Suggestion importance[1-10]: 8

    Why: Making the organization name configurable improves the flexibility and maintainability of the workflow. It prevents potential issues if the organization name changes or is incorrect, which could cause the workflow to fail.

    8
    Improve error handling for unexpected errors during membership checks

    Add error handling for unexpected errors in the checkMembershipForUser API call to
    ensure the workflow does not fail silently or terminate unexpectedly.

    .github/workflows/release-to-branches-in-label.yml [72-73]

     if (error.status !== 404) {
    +  console.error('Unexpected error during membership check:', error);
       throw error;
     }
    Suggestion importance[1-10]: 7

    Why: Adding error logging for unexpected errors during the membership check enhances debugging and ensures that issues can be identified and resolved more easily. However, the improvement is not critical to the workflow's functionality.

    7

    @sharadregoti sharadregoti merged commit 7d30192 into master Jan 3, 2025
    9 checks passed
    @sharadregoti sharadregoti deleted the release-to-branches-in-label branch January 3, 2025 05:45
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants