Skip to content

Commit

Permalink
Merge pull request #219 from maxonfjvipon/master
Browse files Browse the repository at this point in the history
Fix `releases` pipline
  • Loading branch information
yegor256 committed Mar 10, 2024
2 parents 9c2a657 + 3d797dc commit c40cdfa
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/releases.yml
Expand Up @@ -3,6 +3,8 @@ name: releases
on:
schedule:
- cron: "0 * * * *"
env:
make_pr: 'false'

jobs:
check-releases:
Expand Down Expand Up @@ -35,8 +37,9 @@ jobs:
- name: Check if branch exists
run: |
python3 py/is_branch_exist.py ${{ env.eo_lib_version }}
echo "is_exist: ${{ env.is_exist }}"
- name: create pull request
echo "make_pr: ${{ env.make_pr }}"
- name: Create pull request
if: ${{ env.make_pr == 'true' }}
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.TOKEN }}
Expand All @@ -47,4 +50,3 @@ jobs:
base: master
branch: update-${{ env.eo_lib_version }}
delete-branch: true
if: ${{ env.is_exist == 'false' }}
2 changes: 2 additions & 0 deletions py/auto_pull.py
Expand Up @@ -24,6 +24,7 @@ def pull_release(unique_deps):
else:
print(f"{latest_version} is less than or equal to {version}")


def compare(latest_version, old_version):
latest = latest_version.split(".")
old = old_version.split(".")
Expand All @@ -32,4 +33,5 @@ def compare(latest_version, old_version):
return True
return False


pull_release(dependencies())
21 changes: 12 additions & 9 deletions py/is_branch_exist.py
Expand Up @@ -2,16 +2,19 @@
import subprocess
import sys

is_exist = False
make_pr = False
if len(sys.argv) > 1:
eo_lib_version = sys.argv[1]
print('cmd entry:', eo_lib_version)
command = f'git ls-remote --exit-code --heads origin update-{eo_lib_version}'
result = subprocess.run(command, shell=True, capture_output=True)
is_exist = result.returncode == 0
if eo_lib_version != '':
print('cmd entry:', eo_lib_version)
command = f'git ls-remote --exit-code --heads origin update-{eo_lib_version}'
result = subprocess.run(command, shell=True, capture_output=True)
make_pr = result.returncode != 0
else:
print(f"eo_lib_version was not set to sys.argv")
print("eo_lib_version was not set to sys.argv")
env_file = os.getenv('GITHUB_ENV')
with open(env_file, "a") as myfile:
myfile.write(f'is_exist={"true" if is_exist else "false"}')
print(f'Added to env: {is_exist}')
with open(env_file, "a") as file:
env = f'make_pr={"true" if make_pr else "false"}'
file.write(env)
print(f'written to GITHUB_ENV "{env}"')
print(f'Added to env: {make_pr}')

0 comments on commit c40cdfa

Please sign in to comment.