-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (45 loc) · 1.6 KB
/
pr_closed.yaml
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
45
46
47
48
49
50
51
52
name: Pull Request Closed
on:
pull_request:
types: [closed]
jobs:
delete_modal_env:
name: Delete Modal Environment
runs-on: ubuntu-latest
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Modal
run: |
python -m pip install --upgrade pip
pip install modal
- name: Delete Modal Environment
run: |
ENV_NAME=pr${{ github.event.number }}
set +e # Disable immediate exit on error
echo "Deleting Modal environment '$ENV_NAME' if it exists..."
CREATE_OUTPUT=$(modal environment delete --confirm $ENV_NAME 2>&1)
CREATE_EXIT_CODE=$?
set -e # Re-enable immediate exit on error
if [ $CREATE_EXIT_CODE -ne 0 ]; then
if [[ "$CREATE_OUTPUT" == *"AuthError"* ]]; then
echo "Create command output: $CREATE_OUTPUT"
echo "Authentication error occurred. Exiting."
exit 1
elif [[ "$CREATE_OUTPUT" == *"<Status.NOT_FOUND: 5>"* ]]; then
echo "Modal environment '$ENV_NAME' does not exist."
else
echo "Create command output: $CREATE_OUTPUT"
echo "An unknown error occurred. Exiting."
exit 1
fi
else
echo "Modal environment '$ENV_NAME' deleted successfully."
fi