From b47f3a0c512d186f37f7d1fd0b2a27d0b04a4e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9nesis=20=C3=81lvarez?= Date: Thu, 9 May 2024 11:51:45 -0400 Subject: [PATCH] New: adding cloud run instances created by PR when is merged (#202) Co-authored-by: Genesis Alvarez --- .github/workflows/delete-deployment.yml | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/delete-deployment.yml diff --git a/.github/workflows/delete-deployment.yml b/.github/workflows/delete-deployment.yml new file mode 100644 index 00000000..9b7dc18d --- /dev/null +++ b/.github/workflows/delete-deployment.yml @@ -0,0 +1,30 @@ +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.4.1 + + - 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: 'Use gcloud CLI' + run: 'gcloud info' + + - name: Use gcloud CLI + 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