Skip to content

Commit

Permalink
login to git first
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Feb 4, 2024
1 parent c6a574e commit 7fcdfdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/octez_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@ jobs:
uses: actions/checkout@v2
- name: Install python-requests
run: sudo apt-get install python3-requests
- name: python3 octez_version.py
run: python3 octez_version.py

- name: Check the latest Octez release
run: python3 octez_version.py

- name: Create a PR for new version
if: success()
run: |
export OCTEZ_VERSION=$(cat octez_version)
cd ../interface
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout -b octez-$OCTEZ_VERSION
git add .
git commit -m "Update Octez binaries to $OCTEZ_VERSION"
git push origin octez-$OCTEZ_VERSION
gh pr create --title "Update Octez binaries to $OCTEZ_VERSION" --body "This PR updates the Octez binaries to the latest version $OCTEZ_VERSION" --base master --head octez-$OCTEZ_VERSION
13 changes: 4 additions & 9 deletions octez_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,25 @@ def run(*args, **kwargs):


def main():

version_file = Path('octez_version')
current_version = version_file.read_text().strip() if version_file.exists() else ''
print(f'Current version: {current_version}')
latest_version = requests.get(OCTEZ_REPO_URL).url.split("/")[-1]
print(f'Latest version: {latest_version}')

if current_version == latest_version:
return
print('Octez version is up to date.')
exit(1)

if not env.get("GITHUB_ACTIONS"):
print("This script is intended to be run in a GitHub Action.")
exit(1)
exit(2)

print('Octez version has changed. Updating...')
Path('octez_version').write_text(latest_version)

run('make', 'build')
run('git', 'checkout', '-b', f'octez-{latest_version}')
run('git', 'add', 'octez_version')
run('git', 'commit', '-m', f'Update Octez binaries to {latest_version}')
run('git', 'push', 'origin', f'octez-{latest_version}')
run('gh', 'pr', 'create', '-f', '-B', f'octez-{latest_version}', '-t', f'Update Octez binaries to {latest_version}')

exit(0)

if __name__ == "__main__":
main()

0 comments on commit 7fcdfdc

Please sign in to comment.