Skip to content

Commit

Permalink
(maint) Prevent workflow from failing on no-op (#25533)
Browse files Browse the repository at this point in the history
* (maint) Prevent workflow from failing on no change

* Update print statements

* echo new version to test
  • Loading branch information
hestonhoffman authored Oct 2, 2024
1 parent 6181ecc commit cad442f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
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!")
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')

0 comments on commit cad442f

Please sign in to comment.