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

Add Ghcr clean-up workflow #399

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 46 additions & 0 deletions .github/workflows/ghcr-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Delete old ghcr images
on:
schedule:
- cron: "15 1 * * *" # every day at 1:15am
pull_request:
types: [closed]
workflow_dispatch:

jobs:
pull-request-ghcr-cleanup:
if: ${{ github.event_name == 'pull_request' }}
name: Delete images related to closed PR
runs-on: ubuntu-latest
steps:
- name: Delete images related to closed PR
uses: snok/container-retention-policy@v2
with:
image-names: device/*
cut-off: now UTC
account-type: org
org-name: plgd-dev
filter-tags: vnext-pr${{ github.event.pull_request.number }}*
token: ${{ secrets.GHCR_CLEANUP_PAT }}

nightly-ghcr-cleanup:
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }}
name: Delete old vnext images
runs-on: ubuntu-latest
steps:
- name: Delete older than a month vnext images
uses: snok/container-retention-policy@v2
with:
image-names: device/*
cut-off: One month ago UTC
account-type: org
org-name: plgd-dev
filter-tags: vnext-*
skip-tags: vnext-pr*, main
token: ${{ secrets.GHCR_CLEANUP_PAT }}

- name: Delete untagged images with no dependency
uses: Chizkiyahu/delete-untagged-ghcr-action@v3
with:
token: ${{ secrets.GHCR_CLEANUP_PAT }}
owner_type: org
except_untagged_multiplatform: true
5 changes: 3 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ linters-settings:
modules:
- github.com/pkg/errors:
recommendations:
- errors
- errors
stylecheck:
# STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
# Default: ["*"]
checks: [ "all", "-ST1000", "-ST1003" ]
checks: ["all", "-ST1000", "-ST1003"]

linters:
enable:
Expand Down Expand Up @@ -116,6 +116,7 @@ issues:
- path: cmd/ocfclient/main\.go
linters:
- gocognit
- goconst
- gocyclo
- gosec

Expand Down
2 changes: 1 addition & 1 deletion client/updateResource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestClientUpdateResourceInRFOTM(t *testing.T) {
deviceID: deviceID,
href: configuration.ResourceURI,
data: map[string]interface{}{
"n": t.Name() + "-valid",
"n": t.Name() + "-forbidden",
},
opts: []client.UpdateOption{client.WithDiscoveryConfiguration(core.DefaultDiscoveryConfiguration())},
},
Expand Down