-
Notifications
You must be signed in to change notification settings - Fork 8
Delete old releases #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1bc10af
[CI] : Temporarily build against forked torch-mlir to ensure CI build…
sahas3 15016d3
Merge branch 'llvm:main' into main
sahas3 7cdf9fd
[CI] : Delete old release assets due to GH policy of max 1000 assets …
sahas3 c245d99
[CI] : Fail CI if uploading artifacts fail.
sahas3 09578bc
Revert "[CI] : Temporarily build against forked torch-mlir to ensure …
sahas3 5d1fa67
Address feedback
sahas3 733d2c5
Update the check to consider name in addition to ID as well.
sahas3 a9e588b
Simplify asset find + delete logic
sahas3 b3da22b
Fix typo: reads -> read
sahas3 85aba77
Temporarily add a push trigger to try to run CI in forked repo.
sahas3 ad43652
Add explicit reference to github repo.
sahas3 7f9e2b1
Remove github token.
sahas3 fd41959
[revert] : Remove github token.
sahas3 93f14be
[revert] : Remove push trigger.
sahas3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,3 +71,4 @@ jobs: | |
| allowUpdates: true | ||
| replacesArtifacts: true | ||
| makeLatest: true | ||
| artifactErrorsFailBuild: true | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,3 +80,4 @@ jobs: | |
| allowUpdates: true | ||
| replacesArtifacts: true | ||
| makeLatest: true | ||
| artifactErrorsFailBuild: true | ||
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: Delete Old Releases | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 10 * * *' # Daily at 10:00 UTC which is 2:00 AM PST (UTC-8) | ||
| workflow_dispatch: # Manual trigger | ||
| push: | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| clean_releases: | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| runs-on: ubuntu-latest | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| steps: | ||
| - name: Delete old releases | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # To use GitHub CLI in a GitHub Actions workflow, set the GH_TOKEN environment variable | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
sahas3 marked this conversation as resolved.
Show resolved
Hide resolved
sahas3 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Don't run this in everyone's forks on schedule but allow to run via dispatch. | ||
| if: ${{ github.repository_owner == 'llvm' || github.event_name != 'schedule' }} | ||
| run: | | ||
| # Define 60 days in seconds (60 * 24 * 60 * 60 = 5184000) | ||
| SECONDS_60_DAYS=5184000 | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Store the list of asset ID and Name pairs in the variable | ||
| # "ASSET_ID ASSET_NAME" on each line | ||
| ASSETS_TO_DELETE=$(gh api --paginate repos/${{ github.repository }}/releases | \ | ||
| jq -r --argjson cutoff_seconds "$SECONDS_60_DAYS" ' | ||
| # Calculate the 60-day cutoff as now minus 60 days | ||
| . as $releases | (now - $cutoff_seconds) as $cutoff | | ||
| # Iterate through every single asset in every release | ||
| $releases[].assets[] | | ||
| # Convert the asset date string to a numeric timestamp | ||
| (.created_at | fromdateiso8601) as $asset_time | | ||
| # Select assets where the asset_time is older than the cutoff | ||
| select($asset_time < $cutoff) | | ||
| # Output the asset ID and Name, separated by a space | ||
| "\(.id) \(.name)" | ||
| ') | ||
| # Process each asset using a loop to read two space-separated fields from the ASSETS_TO_DELETE variable. | ||
| while IFS=' ' read -r ID NAME; do | ||
| # Check if both ID and NAME were successfully read | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if [ -n "$ID" ]; then | ||
| echo "Deleting old asset: ID $ID (Name: $NAME)" | ||
| gh api --method DELETE repos/${{ github.repository }}/releases/assets/$ID | ||
sahas3 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| fi | ||
| done <<< "$ASSETS_TO_DELETE" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.