Skip to content

Commit

Permalink
adding github action for updating api version
Browse files Browse the repository at this point in the history
  • Loading branch information
costero-e committed Oct 22, 2024
1 parent 2681b66 commit d8d5aba
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/update_api_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: update api version

on:
push:
branches: ['master', 'api-version']

jobs:
updateapiversion:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v3 # checkout the repository content to github runner.
- name: setup python
uses: actions/setup-python@v4
with:
python-version: 3.8 #install the python needed
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: execute py script
run: |
python beacon/conf/api_version.py
git config --global user.email "[email protected]"
git config --global user.name "API version update"
git add .
git commit -m "api version automatically generated"
git push
33 changes: 33 additions & 0 deletions beacon/conf/api_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import subprocess
import yaml


repo_url = 'https://github.com/EGA-archive/beacon2-ri-api.git'
output_lines = subprocess.check_output(
[
"git",
"ls-remote",
repo_url,
"rev-parse",
"--short",
"sort=committerdate",
"HEAD"
],
encoding="utf-8",
).splitlines()

line_ref = output_lines[0].rpartition("/")[-1]

last_line_ref=line_ref[0:7]

last_line_ref="v2.0-"+last_line_ref

print(last_line_ref)

with open("beacon/conf/api_version.yml") as api_version_file:
api_version = yaml.safe_load(api_version_file)

api_version['api_version']=last_line_ref

with open("beacon/conf/api_version.yml", 'w') as out:
yaml.dump(api_version, out)
1 change: 0 additions & 1 deletion beacon/conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

level=logging.NOTSET
log_file='beacon/logs/logs.log'
api_version='2.0.0'
beacon_id = 'org.ega-archive.beacon-ri-demo' # ID of the Beacon
beacon_name = 'Beacon Reference Implementation demo' # Name of the Beacon service
api_version = 'v2.0.0' # Version of the Beacon implementation
Expand Down

0 comments on commit d8d5aba

Please sign in to comment.