Skip to content

Commit

Permalink
Merge pull request #357 from peviitor-ro/sebiboga-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
ale23yfm committed Aug 10, 2024
2 parents 660f3d0 + 7dd6c56 commit f84a896
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/bk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Solr Data Sync Across Multiple BK Servers

on:
push:
branches:
- main # or any branches appropriate for your scenario

jobs:
data-transfer-and-clean:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install jq
run: sudo apt-get update && sudo apt-get install jq

- name: Get Master Solr Server URL
id: solr-server
run: |
echo "MASTER_SOLR_URL=$(curl -s https://api.peviitor.ro/devops/solr/)" >> $GITHUB_ENV
- name: Fetch Data from Master Solr
run: |
curl "${{ env.MASTER_SOLR_URL }}/solr/jobs/select?q=*:*&fl=job_title,job_link,company,hiringOrganization.name,country,remote,jobLocationType,validThrough,city,sursa,id,county&rows=1000000&wt=json&indent=true" -o backup.json
- name: Clean the JSON File
run: jq '.response.docs' backup.json > cleaned_backup.json

# Define servers array for better management and iteration
- name: Define Backup Servers
run: echo "BACKUP_SERVERS=http://peviitor.go.ro:80,http://zimbor.go.ro:8985,http://84.117.157.10:8983,http://srvalx.duckdns.org:8983" >> $GITHUB_ENV

# Iterating over each backup server and uploading data
- name: Upload Data to Backup Servers
run: |
for server in ${BACKUP_SERVERS//,/ }
do
echo "Cleaning data on $server"
curl "$server/solr/jobs/update" -H "Content-Type: text/xml" --data-binary '<delete><query>*:*</query></delete>'
curl "$server/solr/jobs/update" --data '<commit/>'
echo "Uploading data to $server"
curl "$server/solr/jobs/update?commit=true" -H "Content-Type: application/json" --data-binary @cleaned_backup.json
done

0 comments on commit f84a896

Please sign in to comment.