Fly Cleanup #24
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
# Cleans up orphaned test apps on Fly | |
# TODO: check app creation date - could destroy an app during a test run | |
# See <https://github.com/digidem/comapeo-core/issues/914>. | |
name: Fly Cleanup | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 5 * * *' # Every day at 5am UTC | |
jobs: | |
cleanup: | |
name: Cleanup Orphaned Apps | |
runs-on: ubuntu-latest | |
concurrency: deploy-group # optional: ensure only one action runs at a time | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
run: | | |
fly apps list -q -o digidem | while IFS= read -r name; do | |
# Trim leading and trailing whitespace from $name | |
name=$(echo "$name" | xargs) | |
# Check if the name starts with 'comapeo-cloud-test-' | |
if [[ $name == comapeo-cloud-test-* ]]; then | |
# Call the fly destroy command with the name | |
fly apps destroy -y "$name" | |
fi | |
done |