Coder Social home page Coder Social logo

parisbite / remove-package-versions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from navikt/remove-package-versions

0.0 0.0 0.0 37 KB

GitHub Action that can be used to remove older versions of a package from GitHub Packages

License: MIT License

Shell 11.46% PHP 76.84% Dockerfile 11.70%

remove-package-versions's Introduction

Remove old package versions from GitHub Packages

This action will allow you to remove older versions of all GitHub Packages in a private repository.

Usage

To use the action, simply refer to it in your workflow:

name: Remove package versions
on: push
jobs:
  remove-package-versions:
    runs-on: ubuntu-latest
    steps:
    - name: Remove package versions
      id: remove-package-versions
      uses: navikt/remove-package-versions@v0
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The above example will trigger the action whenever the push event occurs. All events that can be used are found in the GitHub documentation.

If you want to run the action periodically instead, use a scheduled workflow:

name: Remove package versions
on:
  schedule:
    - cron:  '0 8 * * *'
jobs:
  remove-package-versions:
    runs-on: ubuntu-latest
    steps:
      - name: Remove package versions
        id: remove-package-versions
        uses: navikt/remove-package-versions@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Note: The underlying HTTP client in this action does not currently do any pagination which means it has a hard limit on 100 packages, and 100 versions per package when fetching the packages / versions to determine what to remove.

Environment variables

The action uses the following environment variables:

GITHUB_TOKEN

A valid token that is used to interact with GitHubs API. This token must have the following scopes:

  • repo
  • read:packages
  • delete:packages

As seen from the above example the autogenerated installation token within a workflow run can be used, so there is no need to generate a personal access token for this purpose.

GITHUB_REPOSITORY

This environment variable is automatically available inside a workflow run, and the format is owner:repo, for instance navikt/remove-package-versions.

Parameters

The action supports the following parameters:

keep_versions

Number of versions to keep per package. Defaults to 5.

keep_latest

Wheter or not to keep the latest version. Defaults to true.

remove_semver

Whether or not to remove semantic versions. Defaults to false.

Keep in mind that if you use date-based versions with . as a separator, for instance yyyy.mm.dd-<sha>, some dates are valid semantic versions, while others aren't. The ones who aren't valid semantic versions are the ones who have the month or day parts of the date starting with 0, for instance 2019.12.01. When using date-based versions it's advisable to use - as a separator instead of ..

Output

The action outputs a JSON-encoded list of removed package versions prefixed with the owner and the repository name. The name of the output is removed_package_versions. Using the id from the workflow example above, you can refer to the output using ${{ steps.remove-package-versions.outputs.removed_package_versions }}.

Releasing a new version

Use the release.sh script to easily tag the main branch:

./release.sh v1.2.3

will create three tags, all pointing to HEAD:

  • v1
  • v1.2
  • v1.2.3

The script will also ask if you want to push the tags. Existing major and/or minor tags will be replaced.

License

MIT, see LICENSE.

remove-package-versions's People

Contributors

christeredvartsen avatar dependabot[bot] avatar msalzburg avatar roygrini avatar

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.