3030 shell : bash
3131 run : |
3232 # Check for any activity in the last 50 days
33+ # Note: date -d is GNU-specific, but this workflow runs on ubuntu-latest which has GNU date
3334 cutoff_date=$(date -u -d '50 days ago' '+%Y-%m-%dT%H:%M:%SZ')
3435 echo "Checking for activity since: $cutoff_date"
3536
@@ -83,7 +84,7 @@ GitHub disables scheduled workflows after 60 days of repository inactivity."
8384 # Create PR
8485 pr_url=$(gh pr create \
8586 --head "$branch_name" \
86- --base main \
87+ --base ${{ github.event.repository.default_branch }} \
8788 --title "chore : keep scheduled workflows alive" \
8889 --body "This automated PR is created to prevent scheduled workflows from being disabled due to inactivity.
8990
@@ -93,8 +94,8 @@ This PR contains an empty commit and will be automatically closed without mergin
9394
9495 echo "Created PR : $pr_url"
9596
96- # Extract PR number from URL
97- pr_number=$(echo "$pr_url" | grep -o '[0-9]* $')
97+ # Extract PR number from URL (require at least one digit)
98+ pr_number=$(echo "$pr_url" | grep -oE '[0-9]+ $')
9899
99100 if [ -n "$pr_number" ]; then
100101 # Close the PR immediately
@@ -106,5 +107,7 @@ This PR contains an empty commit and will be automatically closed without mergin
106107 echo "Deleted branch : $branch_name"
107108 else
108109 echo "Warning : Could not extract PR number from URL: $pr_url"
109- echo "The branch $branch_name was created but PR may not have been closed."
110+ echo "The branch $branch_name was created but PR may not have been properly closed."
111+ echo "Attempting to clean up branch anyway..."
112+ git push origin --delete "$branch_name" 2>/dev/null || echo "Branch cleanup failed, may need manual cleanup"
110113 fi
0 commit comments