Skip to content

Commit

Permalink
feat: add option to disable the cleanup (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
Th3S4mur41 committed Oct 12, 2023
1 parent 30dbf95 commit aa216d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ jobs:
- name: '📝 Creating files and folders'
run: ./test/add_files.sh

- name: '⚙️ Run action'
env:
DISABLE_RUNNER_CLEANUP: true
uses: ./

- name: '✅ Test if workspace is not empty'
shell: bash
run: |
if [ "$(ls -A .)" ]; then
exit 0
else
echo "Workspace is not Empty"
exit 1
fi
- name: '⚙️ Run action'
uses: ./

- name: '✅ Test if workspace is empty'
if: ${{ always() }} # Run even if previous steps in the job fail or are canceled
shell: bash
run: |
if [ "$(ls -A .)" ]; then
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ steps:
- uses: eviden-actions/clean-self-hosted-runner@v1
```
### Options
To disable the cleanup job (e.g. for debugging purpose), set the [environment variable](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#env) `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.
Expand Down
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ runs:
steps:
- id: step-1
name: '🧹 Clean working directory'
if: ${{ always() }} # Run even if the job fails or is canceled
# If you want to disable the cleanup for e.g. debugging purpose, you can set the environment variable DISABLE_RUNNER_CLEANUP to true
if: ${{ always() && !env.DISABLE_RUNNER_CLEANUP}} # Run even if the job fails or is canceled
shell: bash
# TODO: evaluate rm -rf "${{ github.workspace }}"
run: |
Expand Down

0 comments on commit aa216d7

Please sign in to comment.