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

Does Branch Code Reference is being deleted over time? #432

Open
rkhaslarov opened this issue Feb 27, 2024 · 1 comment
Open

Does Branch Code Reference is being deleted over time? #432

rkhaslarov opened this issue Feb 27, 2024 · 1 comment

Comments

@rkhaslarov
Copy link

Scenario:

  • Created a PR with new FF and synced reference, now I see in the list of branches
  • Merged and deleted branch, it's still available in LD as code reference

Is this ok? What's the suggestion only sync main branch?

@jazanne
Copy link
Contributor

jazanne commented Mar 1, 2024

@rkhaslarov thank you for raising this issue. For some time we have had an ongoing issue where branches in LD are not automatically cleaned up when they are deleted from your repo.

I have a few recommendations for running code references

  1. If you don't need to look at non-default branch references within the LD application (this page) https://docs.launchdarkly.com/home/code/code-references#using-code-references, then I would recommend only running THIS tool on the main branch. We have a pull-request specific version of the tool that is great for running on branches and can be found here: https://github.com/launchdarkly/find-code-references-in-pull-request. It doesn't save information to the LD, but does detect flag changes within the PR diff itself.

  2. If you do have a need to view and store branch code references in LD for non-default branches, you can workaround the issue by calling the delete branch api directly. If you are using github actions, here's an example workflow you can use:

name: Delete code references branch
on: delete

jobs:
  branch-delete-tasks:
    runs-on: ubuntu-latest
    steps:
      - name: Delete branch
        if: ${{ github.event.ref_type == 'branch' }}
        env:
          LD_ACCESS_TOKEN: ${{ secrets.LD_ACCESS_TOKEN }}
          LD_BASE_URI: https://app.launchdarkly.com
        run: |
          echo "Deleting branch ${{ github.event.ref }}"
          curl -i -XPOST "$LD_BASE_URI/api/v2/code-refs/repositories/${{github.event.repository.name}}/branch-delete-tasks" \
          -H 'Content-Type: application/json' \
          -H "Authorization: $LD_ACCESS_TOKEN" \
          -d '[
            "${{ github.event.ref }}"
          ]'

I'm sorry for any inconvenience. Please let me know if this addresses your issue.

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

No branches or pull requests

2 participants