Created
September 29, 2023 16:38
-
-
Save infamousjoeg/394bb4f05cdb6544e20b0e8a926f855a to your computer and use it in GitHub Desktop.
GitLab Delete Projects with Last Activity Before Specific Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set your personal access token here | |
personalAccessToken="<personal-access-token>" | |
# Get the list of project IDs for owned projects with last activity before 2020-01-01 | |
project_ids=$(curl --header "PRIVATE-TOKEN: $personalAccessToken" "https://gitlab.com/api/v4/projects?simple=true&per_page=100&owned=true&last_activity_before=2020-01-01T00:00:00Z" | jq -r '.[] | select(.last_activity_at < "2020-01-01T00:00:00Z") | .id') | |
# Loop through each project ID and delete the project | |
for project_id in $project_ids; do | |
echo "Deleting project ID: $project_id" | |
curl --request DELETE --header "PRIVATE-TOKEN: $personalAccessToken" "https://gitlab.com/api/v4/projects/$project_id" | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment