Housekeeping actions#

Housekeeping actions provide for general repository operations such as package cleanup.

Package cleanup of untagged versions#

Action cleaning up untagged package versions published at ghcr.io.

Important

Required GitHub Permissions

  • packages: delete - Required to delete package versions from GitHub Container Registry (GHCR)

Source code for this action

Input

Description

Required

Type

Default

package-name

Package name.

True

string

token

Token with package deletion permissions.

True

string

package-org

Organization where packages are published.

False

string

ansys

allow-last-days

Avoid removing the last N days images: e.g. ‘2’.

False

string

python-version

DEPRECATED ARGUMENT. Desired Python version.

False

string

use-uv

DEPRECATED ARGUMENT. Whether to use uv as the default package manager instead of pip. Default value is ''.

False

string

Examples#

Perform untagged versions cleanup
hk-package-clean-untagged:
  name: "Perform untagged versions cleanup"
  runs-on: ubuntu-latest
  steps:
    - name: "Perform untagged versions cleanup"
      uses: ansys/actions/hk-package-clean-untagged@main
      with:
        package-name: 'mypackage'
        token: ${{ secrets.GITHUB_TOKEN }}

Package cleanup excluding certain versions#

“Action cleaning up all package versions published at ghcr.io except for certain tags.”

Note

If an image matched by tags-kept has multiple tags (which are potentially not in the tags-kept list), then the entire image (with all its tags) will be kept.

Important

Required GitHub Permissions

  • packages: delete - Required to delete package versions from GitHub Container Registry (GHCR)

Source code for this action

Input

Description

Required

Type

Default

package-name

Package name.

True

string

token

Token with package deletion permissions.

True

string

tags-kept

Tags to be kept. Pass them as a list: e.g. ‘latest, latest-unstable’.

True

string

package-org

Organization at which packages are published.

False

string

ansys

allow-last-days

Avoid removing the last N days images: e.g. ‘2’.

False

string

python-version

DEPRECATED ARGUMENT. Desired Python version.

False

string

use-uv

DEPRECATED ARGUMENT. Whether to use uv as the default package manager instead of pip. Default value is ''.

False

string

Examples#

Perform versions cleanup - except certain tags
hk-package-clean-except:
  name: "Perform versions cleanup - except certain tags"
  runs-on: ubuntu-latest
  steps:
    - name: "Perform versions cleanup - except certain tags"
      uses: ansys/actions/hk-package-clean-except@main
      with:
        package-name: 'mypackage'
        token: ${{ secrets.GITHUB_TOKEN }}
        tags-kept: 'latest, latest-unstable'

Auto-merge pull requests#

Action merging dependabot and pre-commit.ci PRs.

Important

Required GitHub Permissions

  • contents: write - Required to merge pull requests

  • pull-requests: write - Required to approve and enable auto-merge on pull requests

Source code for this action

Input

Description

Required

Type

Default

approver

Approver GitHub ID.

True

string

approver-token

Approver GitHub token.

True

string

only-allow-dependabot-patch

Only allow dependabot patch version updates. By default, this is set to false (allowing also minor bumps).

False

boolean

False

Examples#

Automerging dependabot and pre-commit.ci PRs
hk-automerge-prs:
  name: "Automerging dependabot and pre-commit.ci PRs"
  runs-on: ubuntu-latest
  # Only runs if we are on a PR
  if: github.event_name == 'pull_request'
  steps:
    - name: "Automerging dependabot and pre-commit.ci PRs"
      uses: ansys/actions/hk-automerge-prs@main
      with:
        approver: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
        approver-token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}

Migrate fork pull requests#

Migrates pull requests from forks to branches within the main repository, enabling workflows that require repository secrets to run. This action handles team membership verification and automated PR creation during migration. After migration, triggering the action subsequently will sync the migration branch with the latest changes from the fork branch.

When syncing, the migration branch is kept as a mirror of the fork branch. This means than any changes pushed to the fork branch will be reflected in the migration branch after a sync, and any changes made directly to the migration branch (e.g., by maintainers) will be overwritten on the next sync.

Note

This action is designed to be called from workflows triggered by issue comments.

Important

Required GitHub Permissions

  • contents: write - Required to push migration branches to the main repository

  • pull-requests: write - Required to create pull requests, add comments, and manage reactions

Additionally, the provided github-token must have read:org scope to check team membership for authorization.

Source code for this action

Input

Description

Required

Type

Default

pr-number

The pull request number to migrate. This should be the PR number from the fork that needs to be migrated to the main repository.

True

string

comment-id

The comment ID that triggered the migration. Used for adding reactions to indicate success or failure.

True

string

user-triggering

The GitHub username of the user triggering the migration. This user will be verified for team membership before proceeding.

True

string

github-token

GitHub token with permissions to create branches, push code, create pull requests, manage comments/reactions, and check team membership. Typically a bot token with contents: write, pull-requests: write, and read:org permissions.

True

string

bot-username

The username of the bot that will be used for git commits during the migration process.

True

string

bot-email

The email address of the bot that will be used for git commits during the migration process.

True

string

team-slug

The slug of the GitHub team that has permission to trigger migrations. For example, pymapdl-maintainers or pyansys-core.

True

string

organization

The GitHub organization name. Defaults to ansys.

False

string

ansys

repository

The repository name (without organization). If not provided, it will be inferred from the GitHub context.

False

string

Examples#

Migrate fork PR to main repository
hk-migrate-fork-pr:
  name: "Migrate fork PR to main repository"
  runs-on: ubuntu-latest
  # Only runs on issue comments
  if: |
    github.event_name == 'issue_comment' &&
    github.event.issue.pull_request != null &&
    (contains(github.event.comment.body, '@pyansys-ci-bot migrate') ||
     contains(github.event.comment.body, '@pyansys-ci-bot sync'))
  permissions:
    contents: write
    pull-requests: write
  steps:
    - name: "Migrate fork PR"
      uses: ansys/actions/hk-migrate-fork-pr@main
      with:
        pr-number: ${{ github.event.issue.number }}
        comment-id: ${{ github.event.comment.id }}
        user-triggering: ${{ github.event.comment.user.login }}
        github-token: ${{ secrets.PYANSYS_CI_BOT_TOKEN }}
        bot-username: ${{ secrets.PYANSYS_CI_BOT_USERNAME }}
        bot-email: ${{ secrets.PYANSYS_CI_BOT_EMAIL }}
        team-slug: 'pyansys-maintainers'