Skip to content

build(deps): bump google-github-actions/deploy-cloudrun from 2.6.0 to 2.7.1 #49

build(deps): bump google-github-actions/deploy-cloudrun from 2.6.0 to 2.7.1

build(deps): bump google-github-actions/deploy-cloudrun from 2.6.0 to 2.7.1 #49

name: Delete Cloud Run instances on PR closed by merged
on:
pull_request:
branches:
- master
types: [closed]
jobs:
delete-cloud-run:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4.5.0
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GAR_JSON_KEY }}'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
- name: 'Display information about the current gcloud environment'
run: 'gcloud info'
- name: Check if Cloud Run service exists
id: check_service
run: |
SERVICE_NAME=${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}-${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }}
if gcloud run services describe $SERVICE_NAME --region=${{ vars.GCP_REGION }} > /dev/null 2>&1; then
echo "service_exists=true" >> $GITHUB_ENV
else
echo "service_exists=false" >> $GITHUB_ENV
fi
- name: 'Delete service'
if: env.service_exists == 'true'
run: gcloud run services delete ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}-${{ env.GITHUB_HEAD_REF_SLUG || env.GITHUB_REF_SLUG }} --region=${{ vars.GCP_REGION }} --quiet