-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58b320c
commit 923b71b
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Merge Source Configs and Create Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**.yml' | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
merge_yaml: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out the code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Merge Source Configs | ||
run: python merge_configs.py | ||
working-directory: ${{ github.workspace }} | ||
|
||
- name: Get next version | ||
uses: reecetech/[email protected] | ||
id: version | ||
with: | ||
scheme: semver | ||
increment: patch | ||
|
||
- name: Create a new Release | ||
if: github.event.pull_request.merged == true || github.event.ref == 'refs/heads/main' | ||
run: | | ||
release_version=${{ steps.version.outputs.version }} | ||
release_name="v$release_version" | ||
release_body="An updated version of the KYVE Source-Registry." | ||
release_url="https://api.github.com/repos/${GITHUB_REPOSITORY}/releases" | ||
# Create a release using the GitHub API | ||
response=$(curl -X POST "$release_url" \ | ||
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-d '{ | ||
"tag_name": "'"$release_version"'", | ||
"name": "'"$release_name"'", | ||
"body": "'"$release_body"'" | ||
}') | ||
# Upload the merged YAML file as an asset | ||
upload_url=$(echo "$response" | jq -r .upload_url) | ||
upload_url=${upload_url/\{?name,label\}/} | ||
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | ||
-H "Content-Type: application/octet-stream" \ | ||
--data-binary "@registry.yml" \ | ||
"$upload_url?name=registry.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
import yaml | ||
|
||
merged_config = {} | ||
|
||
# Iterate through all config.yml files | ||
for root, dirs, files in os.walk("."): | ||
for file in files: | ||
if file == "config.yml": | ||
chain_id = os.path.basename(root) | ||
with open(os.path.join(root, file), 'r') as stream: | ||
config = yaml.safe_load(stream) | ||
merged_config[chain_id] = config | ||
|
||
# Write the merged config to a new file | ||
with open("registry.yml", "w") as output_file: | ||
yaml.dump(merged_config, output_file) |