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

feat: support packages for a user #168

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
[![CI](https://github.com/bots-house/ghcr-delete-image-action/actions/workflows/ci.yml/badge.svg)](https://github.com/bots-house/ghcr-delete-image-action/actions/workflows/ci.yml)
[![wakatime](https://wakatime.com/badge/github/bots-house/ghcr-delete-image-action.svg)](https://wakatime.com/badge/github/bots-house/ghcr-delete-image-action)

Delete image from [Github Container Registry](https://github.com/features/packages) by tag.
Useful for cleanup of pull request scoped images.
Delete image from [Github Container Registry](https://github.com/features/packages) by tag.
Useful for cleanup of pull request scoped images.


## Usage
## Usage

## Delete image when PR was closed.

Expand All @@ -26,9 +25,9 @@ jobs:
- name: Delete image
uses: bots-house/[email protected]
with:
# NOTE: at now only orgs is supported
owner: bots-house
name: some-web-service
# is_user: true # Set this if owner is a user and not an org
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
tag: pr-${{github.event.pull_request.number}}
Expand All @@ -53,11 +52,11 @@ jobs:
steps:
- uses: bots-house/[email protected]
with:
# NOTE: at now only orgs is supported
owner: bots-house
name: some-web-service
# is_user: true # Set this if owner is a user and not an org
# NOTE: using Personal Access Token
token: ${{ secrets.PAT }}
# Keep latest N untagged images
untagged-keep-latest: 3
```
```
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ inputs:
Delete all untagged images older than N in days.
required: false

is_user:
description: >
Set true if the owner is a user and not an organization.
required: false

runs:
using: "node16"
main: "dist/index.js"
10 changes: 7 additions & 3 deletions actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ async function deleteByTag(config, octokit) {
octokit,
config.owner,
config.name,
config.tag
config.tag,
config.is_user
);

core.info(`🆔 package id is #${packageVersion.id}, delete it...`);
Expand All @@ -17,7 +18,8 @@ async function deleteByTag(config, octokit) {
octokit,
config.owner,
config.name,
packageVersion.id
packageVersion.id,
config.is_user
);

core.info(`✅ package #${packageVersion.id} deleted.`);
Expand All @@ -30,6 +32,7 @@ async function deleteUntaggedOrderGreaterThan(config, octokit) {
octokit,
config.owner,
config.name,
config.is_user,
config.untaggedKeepLatest
);

Expand All @@ -41,7 +44,8 @@ async function deleteUntaggedOrderGreaterThan(config, octokit) {
octokit,
config.owner,
config.name,
pkg.id
pkg.id,
config.is_user
);
} catch (error) {
core.info(`⚠️ package #${pkg.id} not deleted: ${error.message}`);
Expand Down
174 changes: 78 additions & 96 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading