Skip to content

Commit

Permalink
Update check-stale-branches.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshCarter-ops authored Oct 21, 2024
1 parent f7909bc commit a009636
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions .github/workflows/check-stale-branches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,19 @@ jobs:
done
branches_json=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s .)

# echo "Fetched branches: $branches_json"

echo "branches=$(echo $branches_json | jq -c)" >> $GITHUB_OUTPUT

- name: Test Fetch Commit Dates for All Branches
run: |
timeago='90 days ago'
ninety_days_ago=$(date -v -90d +%s)
for branch in $(jq -r '.[]' <<< '${{ steps.branches.outputs.branches }}'); do
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)
for commit_date in $commit_dates; do
dtSec=$(date --date "$commit_date" +'%s')
taSec=$(date --date "$timeago" +'%s')
echo "INFO: dtSec=$dtSec, taSec=$taSec" >&2
[ $dtSec -lt $taSec ] && "echo too old"
# # [ ("$commit_date" | date) < "$(date -v-3m)" ] && echo "New Commit"
# echo "$commit_date"
done
# Print commit dates
# echo "Commit dates for branch $branch:"
# echo "$commit_dates"
for commit_date in $commit_dates; do
epoch='$(date -j -f "%Y-%m-%dT%H:%M:%SZ" "$commit_date" +"%s")'
if [ "$epoch" -lt "$ninety_days_ago" ]; then
echo "Commit: $branch is stale, it is older than 90 Days"
fi
done
done

0 comments on commit a009636

Please sign in to comment.