-
Notifications
You must be signed in to change notification settings - Fork 5
42 lines (39 loc) · 1.3 KB
/
ash.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
name: Kill all the zombies 🧟♂️
on:
schedule:
- cron: '0 */3 * * *'
workflow_dispatch:
jobs:
kill-zombies:
name: I am here to chew gum, and kill stuck jobs, and I am all out of gum!
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Authenticate to Google Cloud
id: "auth"
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GCP_DATAFLOW_SERVICE_KEY }}"
- name: Set up Cloud SDK and upload csv files
uses: google-github-actions/setup-gcloud@v2
- name: Kill all active jobs older than 6 hours
shell: python -u {0}
run: |
import subprocess
import json
jobs = json.loads(subprocess.check_output([
"gcloud", "dataflow", "jobs", "list",
"--created-before=-p6h", "--status=active",
"--filter=name:a618127503*", "--format=json",
"--region=us-central1"
]))
if jobs:
for job in jobs:
subprocess.check_call([
"gcloud", "dataflow", "jobs", "cancel",
str(job["id"]),
"--region=us-central1"
])
env:
GOOGLE_APPLICATION_CREDENTIALS: "${{ steps.auth.outputs.credentials_file_path }}"