delete-package-versions
delete-package-versions copied to clipboard
Doesn't delete the oldest version
The documentation states the following:
Delete oldest version of a package hosted in the same repo as the workflow To delete the oldest version of a package that is hosted in the same repo that is executing the workflow the package-name input is required.
Example:
- uses: actions/delete-package-versions@v1 with: package-name: 'test-package'
Using this script will delete the newest - 1
package, rather than the oldest package. See here:
The action creates images tagged 1586947709 and latest. delete-package-versions
runs and deletes latest
, and it should have deleted 1583451815
according to the documentation.
Imo, a num-old-versions-to-keep
parameter would be more useful and easier to understand.
With the current parameter, it's not really clear what should happen.
Just spent an hour trying to get this action to delete the oldest version, and now found this issue. And YES it would be so much better being able to specify how many versions to keep instead of delete.
(sorry for the tone, I thought GitHub wrote this action, because it is honestly a basic feature, but apparently they didn't, it is contributed by someone else?)
Looking briefly at the code I think the one who wrote this action assumed that the graph query of versions(last: $n)
would order by date. I think it orders by something else. Looks almost like alphabetical to me.
https://github.com/actions/delete-package-versions/blob/9bf8ee67420abae0ca70b3dbe788c2d8a178a02b/src/version/get-versions.ts#L33
@esbiorn By default, it is ordered by creation date according to the GitHub docs: https://developer.github.com/v4/object/packageversion/. Though maybe it's returning in the wrong order? Interesting that the docs say the default ordering for the PackageVersion
type is ASC
, but the default ordering for the versions
field on the Package
type is DESC
: https://developer.github.com/v4/object/package/.
Either way, this issue is straight-up preventing me from using this Action. Every time I publish a new package it'll delete "latest", making it impossible to deploy the latest version.