A typical CI workflow with Github Actions looks like this:
- Check out git repo.
- Build project.
- Deploy to a Demo environment.
- Clean up the Demo environment after a while.
The last step is what everybody usually forgets or doesn't have time to take care of it. Over time, that will lead to orphaned deployments and surprising bills from cloud providers.
Github Action - clean up resources
Use this Github Action to clean up resources after X minutes by triggering a URL endpoint.
Use cases
- After deploying to a demo environment, 1 day later, we want it to clean up itself by triggering an API endpoint to remove that demo environment.
- After running some steps, we want to trigger an endpoint to notify somebody, etc.
Usage
Add this to your Yaml file:
jobs:
clean:
runs-on: ubuntu-latest
steps:
- name: cleanup
uses: ngduc/clean-up-action@master
with:
projectId: setYourProjectId # set your unique projectId, example: myProjectId1
expiryMins: 1440 # after X minutes, invoke the below URL endpoint.
method: 'POST' # one of these methods: GET, POST, PUT, PATCH, DELETE
url: https://some.cleanup.api.endpoint # some URL endpoint to clean up resources.
headers: '' # headers (JSON string).
payload: '{ "someResourceId": 1234 }' # payload for url (JSON string).
I created this little project to help with that cleanup step. I hope you find it useful. Any feedback is appreciated.
Links
- Github repo: https://github.com/ngduc/clean-up-action
- Marketplace link: marketplace/actions/clean-up-resources
- Usage example: https://github.com/ngduc/parcelui/blob/master/.github/workflows/ci.yml#L26-L34
Top comments (0)