-
Notifications
You must be signed in to change notification settings - Fork 377
41 lines (34 loc) · 1.36 KB
/
close-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Close Pull Request
on:
pull_request:
types: [closed]
jobs:
teardown_pr_environment:
name: Teardown Cloud Run PR environment
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
# Grant permissions to `GITHUB_TOKEN` for Google Cloud Workload Identity Provider
permissions:
contents: read
id-token: write
steps:
- uses: "actions/checkout@v3"
- name: Authenticate to Google Cloud
uses: "google-github-actions/auth@v1"
with:
workload_identity_provider: ${{ secrets.GOOGLE_CLOUD_WIP }}
service_account: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: "google-github-actions/setup-gcloud@v1"
with:
version: ">= 435.0.0"
- name: Remove PR environment if exists
run: |
service_name="argilla-quickstart-pr-${{ github.event.pull_request.number }}"
services=$(gcloud run services list --project=argilla-ci --format="value(metadata.name)")
if echo "$services" | grep -q "$service_name"; then
echo "Service '$service_name' exists. Removing it..."
gcloud run services delete $service_name --project=argilla-ci --region=europe-southwest1 --quiet
else
echo "Service $service_name does not exist."
fi