├── action.yml ├── entrypoint.sh ├── Dockerfile ├── README.md └── LICENSE /action.yml: -------------------------------------------------------------------------------- 1 | # see package.yml for usage 2 | name: 'Clean Workspace' 3 | description: 'Deletes all files in the work directory.' 4 | runs: 5 | using: 'docker' 6 | image: 'Dockerfile' 7 | branding: 8 | icon: delete 9 | color: red 10 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e # fail on error 4 | 5 | # include hidden files 6 | # https://askubuntu.com/questions/740805/how-can-i-remove-all-files-from-current-directory-using-terminal 7 | shopt -s dotglob 8 | rm -rf * 9 | 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | 3 | # Copies your code file from your action repository to the filesystem path `/` of the container 4 | COPY entrypoint.sh /entrypoint.sh 5 | 6 | # Code file to execute when the docker container starts up (`entrypoint.sh`) 7 | ENTRYPOINT ["/entrypoint.sh"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clean Github Action 2 | 3 | Simply removes all files from the root directory. 4 | 5 | This is useful to clean residue in workspaces 6 | from previous self-hosted builds which can have a mix of root owned 7 | files that are not able to be removed by the user running the action. 8 | 9 | It seems the checkout action is run as the host user, but files created by other 10 | actions is run by root. The subsequent checkout is unable to remove the files 11 | created from the previous run. Action Runners does not automatically clean up. 12 | 13 | 14 | 15 | ## Usage 16 | 17 | ``` 18 | name: Build with Clean 19 | 20 | on: 21 | push: 22 | branches-ignore: 23 | - master 24 | jobs: 25 | build: 26 | runs-on: self-hosted 27 | steps: 28 | - uses: AutoModality/action-clean@v1 29 | - uses: actions/checkout@v2 30 | - run: echo Hello World 31 | ``` -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 AutoModality 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------