-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5fc499d
commit cc169e3
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Review Environment Cleanup | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
# Generate a GitHub token that can be exchanged with Google Cloud - see | ||
# https://github.com/google-github-actions/auth/tree/v0.6.0#setting-up-workload-identity-federation | ||
permissions: | ||
contents: read | ||
id-token: write | ||
deployments: write # Allows removing deployments on GitHub | ||
|
||
jobs: | ||
teardown_deployment: | ||
name: Teardown deployment | ||
runs-on: ubuntu-latest | ||
env: | ||
GOOGLE_CLOUD_SQL_INSTANCE: sepomex | ||
|
||
steps: | ||
# actions/checkout MUST come before auth | ||
- name: Checkout the code | ||
uses: actions/checkout@v3.1.0 | ||
|
||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v0.8.0 | ||
with: | ||
service_account: github-actions@sepomex-365521.iam.gserviceaccount.com | ||
workload_identity_provider: projects/582875546495/locations/global/workloadIdentityPools/github-pool/providers/github-provider | ||
|
||
- name: Set up gcloud Cloud SDK environment | ||
uses: google-github-actions/setup-gcloud@v0.6.0 | ||
|
||
# - name: Drop the review bucket | ||
# run: |- | ||
# gcloud storage rm --recursive \ | ||
# gs://sepomex-pr${{ github.event.pull_request.number }}-bucket \ | ||
# --quiet | ||
|
||
- name: Drop the review database | ||
run: |- | ||
gcloud sql databases delete \ | ||
sepomex_pr${{ github.event.pull_request.number }} \ | ||
--quiet \ | ||
--instance=${{ env.GOOGLE_CLOUD_SQL_INSTANCE }} | ||
- name: Remove the deployed services from Cloud Run | ||
run: |- | ||
gcloud run services delete \ | ||
sepomex-pr${{ github.event.pull_request.number }} \ | ||
--quiet \ | ||
--platform=managed \ | ||
--region=us-central1 | ||
- name: Deactivate & remove the deployment from Github | ||
uses: bobheadxi/deployments@v1.3.0 | ||
if: always() | ||
with: | ||
step: delete-env | ||
token: ${{ github.token }} | ||
env: ${{ github.head_ref }} |