Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(maint) Prevent workflow from failing on no-op #25533

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/bump_synthetics_worker_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ jobs:
- run: pip install requests semver defusedxml

- name: Find latest synthetic-worker version
id: write-synthetics-worker-version
run: |
python local/bin/py/version_getter.py

- name: echo new version
run: echo ${{ steps.write-synthetics-worker-version.outputs.new_version }}

- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Write version
if: steps.write-synthetics-worker-version.outputs.new_version == 'true'
run: |-
git config user.name documentation-ci
git config user.email [email protected]
Expand All @@ -38,6 +43,7 @@ jobs:

- uses: actions/github-script@v7
name: Propose change with latest versions
if: steps.write-synthetics-worker-version.outputs.new_version == 'true'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
Expand Down
20 changes: 17 additions & 3 deletions local/bin/py/version_getter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
import re
import os
import json
from io import StringIO
import requests
Expand Down Expand Up @@ -60,11 +61,24 @@ def get_versions(keys):
Currently only supports synthetics-windows-pl
'''
if __name__ == "__main__":
github_output = os.getenv('GITHUB_OUTPUT')
PRODUCTS = ["synthetics-windows-pl"]
data = get_data()
keys = get_keys(data)
try:
current_versions = json.load(open('data/synthetics_worker_versions.json'))
except:
current_versions = {}
final_versions = get_versions(keys)
print(final_versions)

with open('data/synthetics_worker_versions.json', 'w') as f:
f.write(json.dumps(final_versions, indent=4, sort_keys=True))
if current_versions != final_versions:
print("New version detected!")
hestonhoffman marked this conversation as resolved.
Show resolved Hide resolved
print(final_versions)
with open('data/synthetics_worker_versions.json', 'w') as f:
f.write(json.dumps(final_versions, indent=4, sort_keys=True))
with open(github_output, 'a', encoding='utf-8') as f:
f.write('new_version=true')
else:
with open(github_output, 'a', encoding='utf-8') as f:
print("No new version detected")
f.write('new_version=false')
Loading