raisedadead / action-docr-cleanup

A GitHub Action to Cleanup DigitalOcean Container Registry

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DigitalOcean Registry Cleanup Action

This action deletes tags older than a specified number of days from a DigitalOcean container registry, excluding the "latest" tag. Before using this action, ensure you've set up doctl and authenticated with DigitalOcean.

Inputs

repository_name

Name of the DigitalOcean container registry repository. Required.

dry_run

If set to true, it will display tags to be deleted without actually deleting them. Default is "false".

days

Number of days. Tags older than these many days will be deleted. Default is "2".

Example usage

- name: Install doctl
  uses: digitalocean/action-doctl@v2
  with:
    token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Log in to DigitalOcean Container Registry with short-lived credentials
  run: doctl registry login --expiry-seconds 1200

- uses: raisedadead/action-docr-cleanup@v1
  with:
    repository_name: 'your-repository-name'
    dry_run: 'true'
    days: '7'

Manual run:

Assuming you have doctl installed and authenticated with your user, you can run the following commands:

doctl registry login --expiry-seconds 1200

For help on the script:

./entrypoint.sh -h

To run the script in dry-run mode:

./entrypoint.sh -d -n <number of days> <repository-name>

To run the script:

./entrypoint.sh -n <number of days> <repository-name>

example:

./entrypoint.sh -n 1 myapp

License

Software: The software as it is licensed under the MIT License, please feel free to extend, re-use, share the code.

About

A GitHub Action to Cleanup DigitalOcean Container Registry

License:MIT License


Languages

Language:Shell 87.9%Language:Dockerfile 12.1%