Skip to content

Commit 6bd62b8

Browse files
committed
fix: workflow condition
1 parent a964e00 commit 6bd62b8

File tree

2 files changed

+65
-5
lines changed

2 files changed

+65
-5
lines changed

.github/helpers/wait-for-docker.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import http.client
2+
import json
3+
import time
4+
import os
5+
import sys
6+
7+
8+
REPO = "supertokens/supertokens-core"
9+
SHA = os.environ.get("GITHUB_SHA")
10+
NAME = os.environ.get("WORKFLOW_NAME", "Publish Dev Docker Image")
11+
12+
st = time.time()
13+
14+
def get_latest_actions():
15+
conn = http.client.HTTPSConnection("api.github.com")
16+
url = f"/repos/{REPO}/actions/runs"
17+
headers = {"User-Agent": "Python-http.client"}
18+
conn.request("GET", url, headers=headers)
19+
response = conn.getresponse()
20+
21+
if response.status == 200:
22+
data = response.read()
23+
runs = json.loads(data)['workflow_runs']
24+
found = False
25+
for run in runs:
26+
if run['head_sha'] == SHA and run['name'] == NAME:
27+
found = True
28+
break
29+
30+
if not found:
31+
print("No matching workflow run found.")
32+
sys.exit(1)
33+
34+
if run["status"] == "completed":
35+
if run["conclusion"] == "success":
36+
print("Workflow completed successfully.")
37+
return True
38+
else:
39+
print(f"Workflow failed with conclusion: {run['conclusion']}")
40+
sys.exit(1)
41+
else:
42+
print(f"Failed to fetch workflow runs: {response.status} {response.reason}")
43+
sys.exit(1)
44+
45+
return False
46+
47+
time.sleep(30) # Wait for 30 seconds before checking
48+
49+
50+
while not get_latest_actions():
51+
print("Waiting for the latest actions to complete...")
52+
time.sleep(10)
53+
if time.time() - st > 600:
54+
print("Timed out waiting for the latest actions.")
55+
sys.exit(1)

.github/workflows/dev-tag.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,17 @@ jobs:
2828
outputs:
2929
tag: ${{ steps.set_tag.outputs.TAG }}
3030
steps:
31-
- name: Wait for Docker build
32-
uses: lewagon/wait-on-check-action@v1.3.4
31+
- uses: actions/setup-python@v4
3332
with:
34-
running-workflow-name: Publish Dev Docker Image
35-
ref: ${{ github.sha }}
36-
repo-token: ${{ secrets.GITHUB_TOKEN }}
33+
python-version: '3.11'
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Wait for Docker build
38+
env:
39+
SHA: ${{ github.sha }}
40+
run: |
41+
python .github/helper/wait-for-docker.py
3742
3843
- name: set tag
3944
id: set_tag

0 commit comments

Comments
 (0)