At the end of my workflow in GitHub actions, a "hidden" "post" job seems to run, and I can't seem to figure out how to ignore or overwrite it. For example, the actions/checkout@v2 action seems to run the following when it's complete:
Post job cleanup.
/usr/bin/git version
git version 2.25.1
/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
http.https://github.com/.extraheader
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/github\.com\/\.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
However, I just want to simply remove the entire repository from my self-hosted runner. Just a simple rm -rf in the directory.
I tried to just add this as a step in my .yml file, but that seems to break the actions/checkout@v2 step that runs after my entire workflow is finished.
How can I clean up the repository entirely on the self-hosted running after the workflow is complete?
I was able to remove the entire repository before actions/checkout@v2 using this:
steps:
- name: 'Cleanup build folder'
run: |
ls -la ./
rm -rf ./* || true
rm -rf ./.??* || true
ls -la ./
- uses: actions/checkout@v2
I've added the ls -la ./ before and after, so I could double-check in the action log if everything was really gone.
The trick is to delete all .??* files as well, since rm -rf ./* won't remove files that start with dot, which meas the .git folder won't be deleted.
By running rm -rf ./.??* we remove all hidden files that have a dot as first character, including the .git folder, and then actions/checkout@v2 will clone the repository properly, just like when running on github runners.
-H
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With