Cleanup #270
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cleanup | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 2 * * *" | |
jobs: | |
cleanup: | |
name: Cleanup old preview environments | |
runs-on: ubuntu-latest | |
steps: | |
# Remove preview environments that are older than 7 days | |
- name: Cleanup stale preview environments | |
run: | | |
curl https://api.render.com/v1/services -H 'Authorization: Bearer ${{ secrets.RENDER_API_KEY }}' -H 'Accept: application/json' | \ | |
jq -r '.[].service | select(.name | contains("gustavocunha-preview-pr-")) | select(.updatedAt <= (now|strftime("%Y-%m-%dT%H:%M:%SZ") | fromdate - (7*24*60*60)|strftime("%Y-%m-%dT%H:%M:%Z"))) | .id' | \ | |
xargs -IID curl -X DELETE https://api.render.com/v1/services/ID -H 'Authorization: Bearer ${{ secrets.RENDER_API_KEY }}' -H 'Accept: application/json' |