-
Notifications
You must be signed in to change notification settings - Fork 377
44 lines (36 loc) · 1.45 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
42
43
44
name: Close Pull Request
on:
pull_request:
types: [ closed ]
jobs:
teardown_pr_environment:
name: Teardown Cloud Run PR environment
runs-on: ubuntu-latest
# 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: Get Docker image tag from GITHUB_REF
id: docker-image-tag-from-ref
uses: ./.github/actions/docker-image-tag-from-ref
- name: Remove PR environment if exists
run: |
service_name="argilla-quickstart-${{ steps.docker-image-tag-from-ref.outputs.docker-image-tag }}"
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