actions / actions/runner

Support for execute cmd/scripts for cleanup on Complete Job

Open
#1,143 1 comment 19 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement future
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the enhancement
Being able to execute scripts/commands on hosted machine for cleanup (remove files, change permisions, whatever...) on Complete Job phase, for example before Cleaning up orphan processes

This could be configured using config flags like "context.Global.Variables" to allow this option or setup command/script to execute.

Additional information
For self-hosted runners if pipeline uses docker commands in all forms (containers, services, docker actions, docker run) that causes RW problems due creation of files with root ownership. Documented in other issues like https://github.com/actions/runner/issues/434
Solution of executing actions-runner as root also derivates on other problems. Ex: On nodejs some component like jest-runner can have problems using root privileges, that can causes that process "freezes" and job will end once we reach runner job time limit.

Other problems that we have with custom runners is that files are persisted between jobs if we don't do manual cleanups (checkout, rm step...). Being able to clean it at complete job could be nice.

On summary, if we are able to execute some bash script at end of job execution we can:

  • remove files from previous jobs
  • fix privilege permisions (toolscache, workdir, whatever)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/Runner.Worker/JobExtension.cs around line 512 and the use of context.Global.Variables. Compare the requested Complete Job cleanup behavior with the self-hosted runner and Docker problems described here and in issue 434. Done would mean a defined, configurable command or script execution point before orphan-process cleanup, with its behavior documented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, docker, github-actions
Domain
ci-cd, devops, infrastructure
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.