-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve version check during deployment (#4285)
- Loading branch information
1 parent
c71c178
commit df4724c
Showing
2 changed files
with
68 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: 'Wait for deployment' | ||
description: 'Wait fr deployment' | ||
inputs: | ||
url: | ||
description: 'URL' | ||
required: true | ||
githash: | ||
description: 'Githash' | ||
required: true | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Wait for deployment | ||
run: | | ||
import requests | ||
import os | ||
import time | ||
attempts = 0 | ||
new_version_live_counter = 0 | ||
while new_version_live_counter < 3: | ||
response = requests.get(os.getenv('URL')) | ||
try: | ||
commit = response.json()['version'] | ||
if commit == os.getenv('GITHASH'): | ||
print('New version live') | ||
new_version_live_counter = new_version_live_counter + 1 | ||
time.sleep(1) | ||
continue | ||
else: | ||
print('Commit hash does not match. Retrying...') | ||
except Exception as e: | ||
print('Failed to get version', e) | ||
attempts += 1 | ||
if attempts > 30: | ||
print('Failed to get new version') | ||
exit(1) | ||
time.sleep(attempts) | ||
shell: python | ||
env: | ||
URL: ${{ inputs.url }} | ||
GITHASH: ${{ inputs.githash }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters