-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #357 from peviitor-ro/sebiboga-patch-1
- Loading branch information
Showing
1 changed file
with
44 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,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 |