From 56fdac82872b29d1e3d46a52e96e25aea9f71670 Mon Sep 17 00:00:00 2001 From: TaylorHalf Date: Fri, 18 Oct 2024 12:54:57 +0100 Subject: [PATCH] Testing --- .github/workflows/check-stale-branches.yaml | 23 ++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/.github/workflows/check-stale-branches.yaml b/.github/workflows/check-stale-branches.yaml index 45ed87c..135d744 100644 --- a/.github/workflows/check-stale-branches.yaml +++ b/.github/workflows/check-stale-branches.yaml @@ -49,21 +49,16 @@ jobs: - name: Get commit dates older than stale branch threshold env: - stale-branch-threshold: "3m" + stale-branch-threshold: "3m" run: | - three_months_ago=$(date -v-${{ env.stale-branch-threshold }}) + three_months_ago=$(date -v-${{ env.stale-branch-threshold }} '+%Y-%m-%d') for branch in $(jq -r '.[]' <<< '${{ steps.branches.outputs.branches }}'); do - # Fetch commit dates for the branch - commit_dates=$(gh api \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/dvsa/cvs-svc-app-logs/commits?sha=$branch \ - --jq '.[].commit.committer.date' 2>/dev/null) + # Search commits in the branch where the author date is older than 3 months + commits=$(gh search commits --author-date="<${three_months_ago}" --repo dvsa/cvs-svc-app-logs --branch $branch --limit 100 --json commit,committerDate --jq '.[] | "\(.commit.oid) \(.committerDate)"') - for commit_date in $commit_dates; do - if [[ "$commit_date" < "$three_months_ago" ]]; then - echo "Branch $branch has commits older than $three_months_ago=: $commit_date" - fi - done - done + if [ -n "$commits" ]; then + echo "Branch $branch has commits older than $three_months_ago:" + echo "$commits" + fi + done