Git Product home page Git Product logo

delete-untagged-ghcr-action's People

Contributors

btbn avatar chizkiyahu avatar github-actions[bot] avatar mering avatar yubiuser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

delete-untagged-ghcr-action's Issues

Selective tags cleanup

Provide options to filter images to delete based on tag regex or created or updated date like GitLab.

For example, I would like to cleanup release candidate images (prefixed by candidate/) after 90 days but always keep release images (prefixed by v).

b'no such manifest

docker manifest inspect ghcr.io/plhw/lab-docker/php@sha256:b542bffe4c15244b7e073d711ac91b4cdb71208e2d6bbb8846e1dd576cfa3f51
Traceback (most recent call last):
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 231, in <module>
    delete_pkgs(
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 131, in delete_pkgs
    deps_pkgs = get_deps_pkgs(owner, tagged_pkgs)
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 95, in get_deps_pkgs
    ids.extend(get_image_deps(image))
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 100, in get_image_deps
    manifest_txt = get_manifest(image)
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 110, in get_manifest
    raise Exception(res.stderr)
Exception: b'no such manifest: ghcr.io/plhw/lab-docker/php@sha256:b542bffe4c15244b7e073d711ac91b4cdb71208e2d6bbb8846e1dd5[76](https://github.com/plhw/lab-docker/actions/runs/4572531190/jobs/8071994976#step:3:76)cfa3f51\n'
Error: Process completed with exit code 1.

and

docker manifest inspect ghcr.io/plhw/lab-docker/php@sha256:b542bffe4c15244b7e073d711ac91b4cdb71208e2d6bbb8846e1dd576cfa3f51
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 231, in <module>
    delete_pkgs(
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 131, in delete_pkgs
    deps_pkgs = get_deps_pkgs(owner, tagged_pkgs)
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 95, in get_deps_pkgs
    ids.extend(get_image_deps(image))
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 100, in get_image_deps
    manifest_txt = get_manifest(image)
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 110, in get_manifest
    raise Exception(res.stderr)
Exception: b'manifest unknown\n'
      - name: "Purge Untagged Packages"
        uses: Chizkiyahu/delete-untagged-ghcr-action@v2
        with:
          token: ${{ secrets.PAT_TOKEN }}
          repository_owner: ${{ github.repository_owner }}
          untagged_only: true
          owner_type: org # or user
          except_untagged_multiplatform: true

Looking at my packages, which are multiplatform, i did notice packages with an unknown/unknown platform in them, which is weird also...

anyway, mayby there is a simple fix... thx!

issues with images with no manifest

Apparently (for whatever reason) some images are generated with no manifest, and this causes the action to fail.

Run Chizkiyahu/delete-untagged-ghcr-action@v2
  with:
    token: ***
    repository_owner: zaphiro-technologies
    repository: zaphiro-technologies/data-download-backend
    untagged_only: true
    owner_type: org
    except_untagged_multiplatform: true
Run actions/setup-python@v4
Installed versions
Run pip install -r /home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v[2](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:2)/requirements.txt
Collecting requests (from -r /home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/requirements.txt (line 1))
  Downloading requests-2.[3](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:3)1.0-py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 kB 2.1 MB/s eta 0:00:00
Collecting charset-normalizer<[4](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:4),>=2 (from requests->-r /home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/requirements.txt (line 1))
  Downloading charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.2/199.2 kB 3.3 MB/s eta 0:00:00
Collecting idna<4,>=2.[5](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:5) (from requests->-r /home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/requirements.txt (line 1))
  Downloading idna-3.4-py3-none-any.whl ([6](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:6)1 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 kB 10.1 MB/s eta 0:00:00
Collecting urllib3<3,>=1.21.1 (from requests->-r /home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/requirements.txt (line 1))
  Downloading urllib3-2.0.3-py3-none-any.whl (123 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.6/123.6 kB 8.[7](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:7) MB/s eta 0:00:00
Collecting certifi>=2017.4.17 (from requests->-r /home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/requirements.txt (line 1))
  Downloading certifi-2023.5.7-py3-none-any.whl (156 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.0/157.0 kB 10.9 MB/s eta 0:00:00
Installing collected packages: urllib3, idna, charset-normalizer, certifi, requests
Successfully installed certifi-2023.5.7 charset-normalizer-3.1.0 idna-3.4 requests-2.31.0 urllib3-2.0.3

Notice:  A new release of pip is available: 22.0.4 -> 23.1.2
Notice:  To update, run: pip install --upgrade pip
Run args="--token *** "
args: --token ***  --repository_owner zaphiro-technologies  --repository zaphiro-technologies/data-download-backend  --untagged_only true  --except_untagged_multiplatform true  --owner_type org 
docker manifest inspect ghcr.io/zaphiro-technologies/data-download-api@sha256:023a074442207c9901a415ecb927b[8](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:8)c5eca7e74e87bb26b745ff4772b6e3dce7
Traceback (most recent call last):
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 231, in <module>
    delete_pkgs(
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 131, in delete_pkgs
    deps_pkgs = get_deps_pkgs(owner, tagged_pkgs)
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line [9](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:10)5, in get_deps_pkgs
    ids.extend(get_image_deps(image))
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 100, in get_image_deps
    manifest_txt = get_manifest(image)
  File "/home/runner/work/_actions/Chizkiyahu/delete-untagged-ghcr-action/v2/clean_ghcr.py", line 110, in get_manifest
    raise Exception(res.stderr)
Exception: b'no such manifest: ghcr.io/zaphiro-technologies/data-download-api@sha256:023a074442207c9901a[41](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:45)5ecb927b8c5eca7e74e87bb26b7[45](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:49)ff[47](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:51)[72](https://github.com/zaphiro-technologies/data-download-backend/actions/runs/5209690471/jobs/9400797548#step:3:77)b6e3dce7\n'
Error: Process completed with exit code 1.

Would it make sense to simply simply move to the next image and report warning for these cases?

Feature request; add an except multi-platform flag

When building multi-platform images there are untagged versions created for the images per platform. These should not be deleted or the tagged version won't work anymore.

Would you consider adding a flag --except-untagged-multiplatform or something along those lines?

I think this should get all tags, read the references in the manifest and filter those from the untagged.

Unfortunately, i don't speak Python so a PR isn't doable on short notice.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.