From 9d79739b26478b7f87a062028d4b9ddd0d9e4ac0 Mon Sep 17 00:00:00 2001 From: Tyler Mizuyabu Date: Wed, 3 Apr 2024 13:13:48 -0400 Subject: [PATCH] updated workflow --- .../.github/workflows/drift-detection.yaml | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/organizations/.github/workflows/drift-detection.yaml b/organizations/.github/workflows/drift-detection.yaml index c394607..9973544 100644 --- a/organizations/.github/workflows/drift-detection.yaml +++ b/organizations/.github/workflows/drift-detection.yaml @@ -110,15 +110,32 @@ jobs: `; - const date = new Date(); - - github.rest.issues.create({ + const issues = (await github.rest.issues.listForRepo({ owner: context.repo.owner, repo: context.repo.repo, - title: `Drift Detected ${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`, - body: output, - labels: [drift_label, action_required_label] - }) + labels: drift_label, + sort: 'created', + direction: 'desc', + per_page: 1 + })).data; + + if (issues.length == 0) { + github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: 'Drift Detected', + body: output, + labels: [drift_label, action_required_label] + }); + }else { + github.rest.issues.update({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issues[0].number, + body: output, + labels: [drift_label, action_required_label] + }); + } re-run-apply: permissions: @@ -126,7 +143,7 @@ jobs: id-token: 'write' pull-requests: 'write' issues: 'write' - name: "Run Drift Detection" + name: "Run Apply" if: github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'Re-Apply' runs-on: ubuntu-latest defaults: