From 59b40f36d98295c7ca78dc897650b8ae1fc3378d Mon Sep 17 00:00:00 2001 From: Matt Bishop Date: Fri, 26 Jan 2024 14:20:12 -0500 Subject: [PATCH] Feature flag code reference collection (#3444) * Feature flag code reference collection * Provide project * Try another key * Use different workflow * Touch a feature flag to test detection * Adjust permissions * Remove another flag * Bump workflow * Add label * Undo changes to constants * One more test * Fix logic * Identify step * Try modified * Adjust a flag * Remove test * Try with Boolean * Changed * Undo flag change again * Ignore Renovate Co-authored-by: MtnBurrit0 <77340197+mimartin12@users.noreply.github.com> * Line break --------- Co-authored-by: MtnBurrit0 <77340197+mimartin12@users.noreply.github.com> --- .github/workflows/code-references.yml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/code-references.yml diff --git a/.github/workflows/code-references.yml b/.github/workflows/code-references.yml new file mode 100644 index 000000000..ca584a1d3 --- /dev/null +++ b/.github/workflows/code-references.yml @@ -0,0 +1,42 @@ +--- +name: Collect code references + +on: + pull_request: + branches-ignore: + - "renovate/**" + +permissions: + contents: read + pull-requests: write + +jobs: + refs: + name: Code reference collection + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Collect + id: collect + uses: launchdarkly/find-code-references-in-pull-request@2e9333c88539377cfbe818c265ba8b9ebced3c91 # v1.1.0 + with: + project-key: default + environment-key: dev + access-token: ${{ secrets.LD_ACCESS_TOKEN }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Add label + if: steps.collect.outputs.any-changed == 'true' + run: gh pr edit $PR_NUMBER --add-label feature-flag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + + - name: Remove label + if: steps.collect.outputs.any-changed == 'false' + run: gh pr edit $PR_NUMBER --remove-label feature-flag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }}