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

Pulling changes from main into json. #1

Merged
merged 3 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/generate_json.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This is a basic workflow to help you get started with Actions

name: Generate_Json

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout repo content
uses: actions/checkout@v3

- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.11

- name: install python packages
run: |
python -m pip install --upgrade pip
pip install PyYAML

- name: Execute json_generator
run: python json_generator.py

- name: Commit json file
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add datasets.json
git commit -m "Generating new json file."

- name: Push changes to json branch
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: json


10 changes: 10 additions & 0 deletions json_generator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import yaml, glob, json

import glob
dataset = {"data": []}
for file in glob.glob("./datasets/*.yaml"):
with open(file, 'r') as yaml_file:
dataset['data'].append(yaml.safe_load(yaml_file))

with open('datasets.json', 'w') as file:
file.write(json.dumps(dataset, indent=2))
Loading