Skip to content

ENV Ephemeral: cleanup #265

ENV Ephemeral: cleanup

ENV Ephemeral: cleanup #265

# Copyright (C) 2022 Dynamic Solutions
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: 'ENV Ephemeral: cleanup'
permissions:
id-token: write
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
cleanup-ephemeral-envs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Authenticate to Google Cloud
id: auth
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: ${{ vars.GCP_DEV_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_DEV_SERVICE_ACCOUNT_EMAIL }}
- name: Destroy Cloud Run service
run: |
environments=$(gcloud run services list --format json | jq '.[] | .metadata.name' -r)
for env in $environments; do
if [[ $env == websight-cms-* ]]; then
gcloud run services delete -q $env --region=${{ vars.GCP_DEFAULT_REGION }}
fi
done