Skip to content
eviden-actions

GitHub Action

Clean self-hosted runner

v1.3.2 Latest version

Clean self-hosted runner

eviden-actions

Clean self-hosted runner

Clean working directory on self-hosted runners

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Clean self-hosted runner

uses: eviden-actions/[email protected]

Learn more about this action in eviden-actions/clean-self-hosted-runner

Choose a version

clean-self-hosted-runner

GitHub Actions to clean the working directory on self hosted runners

Release

Per the official documentation, self-hosted runners don't need to have a clean instance for every job execution. Your job might however need a clean working directory for every execution.

The goal of this action is to clean the working directory at the beginning or the end of each job.

Usage

steps:
  - uses: eviden-actions/clean-self-hosted-runner@v1

Options

To disable the cleanup job (e.g. for debugging purpose), set the environment variable DISABLE_RUNNER_CLEANUP to true

Example

This is an example of a simple NPM build workflow that will clean the working directory after each execution.

name: My Workflow

on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  build:
    runs-on: self-hosted

    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v3
      - run: npm ci
      - run: npm run build
      - uses: eviden-actions/clean-self-hosted-runner@v1
        if: ${{ always() }} # Run even if previous steps in the job fail or are canceled