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

[chore] Add IPFS Upload CI/CD #4

Merged
merged 16 commits into from
Oct 7, 2024
Merged
41 changes: 41 additions & 0 deletions .github/scripts/merge_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import json
warittornc marked this conversation as resolved.
Show resolved Hide resolved
import os
import sys
import yaml

from collections import defaultdict, OrderedDict


def main(input_path: str, output_path: str):
shared_prefix_traits: dict[str, dict] = {}

iter_ = os.walk(input_path)
root, dirs, files = iter_.__next__()
for d in dirs:
if (file := f"{d}.yaml") in files:
with open(os.path.join(root, file), 'r') as f:
shared_prefix_traits[d] = yaml.safe_load(f)
else:
print(f"Missing {d}.yaml")
exit(1)

for root, _, files in iter_:
signal_ids: dict[str, OrderedDict] = defaultdict(OrderedDict)
prefix = root.split('/')[-1]
for file in sorted(files):
with open(os.path.join(root, file), 'r') as f:
signal_id = file.split('.')[0]
prefixed_signal_id = f"{prefix}:{signal_id}"

signal_ids[prefixed_signal_id].update(yaml.safe_load(f))
signal_ids[prefixed_signal_id].update(shared_prefix_traits[prefix])

if not os.path.exists(output_path):
os.makedirs(output_path)

with open(f"{output_path}/registry.json", 'w') as f:
json.dump(signal_ids, f, indent=4)


if __name__ == '__main__':
main(*sys.argv[1:])
29 changes: 29 additions & 0 deletions .github/workflows/upload_ipfs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Upload IPFS
on:
push:
tags:
- "v*"

jobs:
upload-ipfs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Upload to IPFS
id: upload
uses: aquiladev/[email protected]
warittornc marked this conversation as resolved.
Show resolved Hide resolved
with:
path: ./signals
service: pinata
pinata_api_key: ${{ secrets.PINATA_API_KEY }}
pinata_secret_api_key: ${{ secrets.PINATA_SECRET_API_KEY }}

- name: Create Checksum File
run: echo $ {{ steps.upload.outputs.hash }} > checksum.txt && cat checksum.txt

- name: Add Checksum File
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: checksum.txt
Loading
Loading