Merge pull request #264 from filecoin-project/filecoin-registry-bot #32
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
name: Update active allocators | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
paths: | |
- 'Allocators/**/*.json' | |
push: | |
branches: | |
- main | |
paths: | |
- 'Allocators/**/*.json' | |
jobs: | |
watch_jsons: | |
runs-on: ubuntu-latest | |
env: | |
BACKEND_URL: https://api.allocator.tech | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Find changed JSON files in Allocator folder | |
id: find_json | |
run: | | |
echo "Searching for JSON files in 'Allocators' folder..." | |
FILES_CHANGED=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep 'Allocators/.*\.json$' | while read -r line; do echo -n "\"$line\","; done) | |
FILES_CHANGED="${FILES_CHANGED%,}" # Remove the trailing comma | |
echo "Files changed: $FILES_CHANGED" | |
echo "::set-output name=files_changed::$FILES_CHANGED" | |
- name: Notify Backend Service | |
if: steps.find_json.outputs.files_changed != '' | |
run: | | |
FILES_JSON="{\"files_changed\":[$(echo ${{ steps.find_json.outputs.files_changed }} | sed 's/\([^,]*\)/"\1"/g')]}" | |
echo "JSON being sent: $FILES_JSON" | |
curl --header "Content-Type: application/json" \ | |
--request POST \ | |
--data "$FILES_JSON" \ | |
"${BACKEND_URL}/allocator/create" |