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

CI: automatically update the repo every 5 days #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/deploy.yaml
@@ -0,0 +1,43 @@
name: Run Python Script and Commit Changes

on:
push:
branches:
- main
schedule:
- cron: '0 0 */5 * *' # Runs every 5 days at midnight
workflow_dispatch: # Allows manual triggering

jobs:
run-and-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
fetch-depth: 0 # fetch all history for all tags and branches

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8' # Set the Python version you need

- name: Install dependencies
run: |
python -m pip install --upgrade pip GitPython packaging lxml emit xmltodict
# Add any other dependencies here

- name: Run Python script
run: |
python scripts/run_param_parse.py
python scripts/json_from_xml.py

- name: Commit and push if changed
run: |
git config --global user.name 'Git bot'
git config --global user.email 'bot@noreply.github.com'
git status
git add .
git diff --staged --quiet || git commit -m "Update metadata"
git push

8 changes: 5 additions & 3 deletions scripts/run_param_parse.py
Expand Up @@ -122,16 +122,18 @@ def run(self):
except Exception as exception:
print(exception)

output = f'/tmp/output'
output = Path(__file__).parent.parent
subprocess.run(['mkdir', '-p', output])
dest = f"{output}/{folder_name}"
subprocess.run(['mkdir', '-p', dest])
for data in glob.glob(f'{dest}/*'):
os.remove(data)
for data in glob.glob(f'{self.repository_path}/Parameter*'):
shutil.move(data, dest)
shutil.copy2(data, dest)
os.remove(data)
for data in glob.glob(f'{self.repository_path}/apm.pdef.*'):
shutil.move(data, dest)
shutil.copy2(data, dest)
os.remove(data)



Expand Down