Skip to content
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

Cleanup old Docker images #2533

Merged
merged 45 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
407b615
aa
wqhhust Apr 29, 2023
5a9f184
aa
wqhhust Apr 29, 2023
6a00627
aa
wqhhust Apr 29, 2023
e60529e
aa
wqhhust Apr 29, 2023
2bc4b0e
aa
wqhhust Apr 29, 2023
b97bd78
aa
wqhhust Apr 29, 2023
e676cec
Update clear.yml
wqhhust Apr 29, 2023
f82c0dc
aa
wqhhust Apr 29, 2023
d996268
Update clear.yml
wqhhust Apr 29, 2023
fec9b23
aa
wqhhust Apr 29, 2023
1440932
aa
wqhhust Apr 29, 2023
2a58a0b
aa
wqhhust Apr 29, 2023
ff2dd8d
aa
wqhhust Apr 29, 2023
baece81
aa
wqhhust Apr 29, 2023
c4a4c66
aa
wqhhust Apr 29, 2023
a41a336
Update clear.yml
wqhhust Apr 29, 2023
1069af2
Update clear.yml
wqhhust Apr 29, 2023
411c977
Update clear.yml
wqhhust Apr 29, 2023
a7b73f1
Update clear.yml
wqhhust Apr 29, 2023
9e4fade
Update clear.yml
wqhhust Apr 29, 2023
60cdcad
Update clear.yml
wqhhust Apr 29, 2023
212a706
Update clear.yml
wqhhust Apr 29, 2023
0fec923
Update cleantool.go
wqhhust Apr 29, 2023
cd32337
aa
wqhhust Apr 29, 2023
0417e74
Update clear.yml
wqhhust Apr 29, 2023
9601530
aa
wqhhust Apr 30, 2023
49a4eee
aa
wqhhust May 2, 2023
2578623
aa
wqhhust May 2, 2023
c3a578c
aa
wqhhust May 2, 2023
33ed5eb
aa
wqhhust May 2, 2023
dcbcec6
aa
wqhhust May 2, 2023
e2370ad
aa
wqhhust May 2, 2023
e59448b
aaa
wqhhust May 3, 2023
092ad00
Merge branch 'main' into main
AlekSi May 3, 2023
6150cdf
commit
wqhhust May 3, 2023
1552427
aa
wqhhust May 3, 2023
81ea34c
aa
wqhhust May 3, 2023
4bfb347
aa
wqhhust May 3, 2023
25df91a
run go mod tidy
wqhhust May 4, 2023
1f7aaef
aa
wqhhust May 11, 2023
88bd79c
Merge remote-tracking branch 'upstream/main'
wqhhust May 11, 2023
d68a9eb
run lint
wqhhust May 12, 2023
269cf6e
Merge branch 'main' into main
AlekSi May 12, 2023
244fe7c
Bump deps
AlekSi May 12, 2023
a20e263
Disable workflow for now
AlekSi May 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
aa
  • Loading branch information
wqhhust committed May 2, 2023
commit 49a4eee4fa201f116a2045743b7e0b0f4ebcbd58
7 changes: 4 additions & 3 deletions .github/workflows/clear.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@

name: clear old packages
on: workflow_dispatch
# schedule:
# - cron: "0 0 * * *"
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
scan-old-package:
Expand Down
28 changes: 20 additions & 8 deletions cmd/cleantool/cleantool.go
wqhhust marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2021 FerretDB Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main
AlekSi marked this conversation as resolved.
Show resolved Hide resolved

import (
Expand All @@ -9,7 +23,6 @@ import (
"time"

"github.com/google/go-github/v52/github"
wqhhust marked this conversation as resolved.
Show resolved Hide resolved
"github.com/sethvargo/go-githubactions"
"golang.org/x/oauth2"
)

Expand All @@ -30,13 +43,14 @@ func main() {
orgName := "FerretDB"
daysBack := 90
pageSize := 100
pageIndex := 1
var versions []string
for i := 1; i < 100; i++ {
listOption := github.ListOptions{Page: i, PerPage: pageSize}
for {
listOption := github.ListOptions{Page: pageIndex, PerPage: pageSize}
packageListOption := github.PackageListOptions{ListOptions: listOption}
packages, _, err := client.Organizations.PackageGetAllVersions(ctx, orgName, packageType, packageName, &packageListOption)
if err != nil {
log.Printf("Failed to get versions for page %d", i)
log.Printf("Failed to get versions for page %d", pageIndex)
}
for _, v := range packages {
if time.Now().After(v.UpdatedAt.Add(time.Duration(daysBack) * 24 * time.Hour)) {
Expand All @@ -47,14 +61,12 @@ func main() {
}
}
if len(packages) < pageSize {
log.Printf("Come to the last page (page %d)", i)
log.Printf("Come to the last page (page %d)", pageIndex)
break
}

pageIndex++
}
log.Println(versions)
staleVersions := strings.Join(versions, ", ")
log.Printf("Setting STALE_VERSIONS to %q.", staleVersions)
githubactions.SetEnv("STALE_VERSIONS", staleVersions)

}