48 lines
1.8 KiB
YAML
48 lines
1.8 KiB
YAML
name: Sync Label Studio
|
|
|
|
on:
|
|
schedule:
|
|
# This job will run every day at 03:00 AM
|
|
- cron: "0 3 * * *"
|
|
|
|
jobs:
|
|
sync_storage:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Sync Label Studio Target Storage
|
|
env:
|
|
LABEL_STUDIO_API_TOKEN: ${{ secrets.LABEL_STUDIO_API_TOKEN }}
|
|
run: |
|
|
curl -X POST \
|
|
-H "Authorization: Token $LABEL_STUDIO_API_TOKEN" \
|
|
"https://label-studio.gt-proj.com/api/storages/export/s3/1/sync"
|
|
|
|
- name: Install MinIO Client
|
|
run: |
|
|
wget https://dl.min.io/client/mc/release/linux-amd64/mc
|
|
chmod +x mc
|
|
sudo mv mc /usr/local/bin/
|
|
|
|
- name: Fix Label Studio output content type in MinIO
|
|
env:
|
|
MINIO_ACCESS_KEY: ${{ secrets.MINIO_ACCESS_KEY }}
|
|
MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }}
|
|
run: |
|
|
mc alias set myminio http://10.0.0.2:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
|
|
mc cp --recursive --attr 'Content-Type=application/json' \
|
|
myminio/visual-semiotic-ai-analysis/label-studio-output/ \
|
|
myminio/visual-semiotic-ai-analysis/label-studio-output/
|
|
|
|
- name: Ensure .json extension on files
|
|
env:
|
|
MINIO_ACCESS_KEY: ${{ secrets.MINIO_ACCESS_KEY }}
|
|
MINIO_SECRET_KEY: ${{ secrets.MINIO_SECRET_KEY }}
|
|
run: |
|
|
mc alias set myminio http://10.0.0.2:9000 $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
|
|
for file in $(mc ls --recursive myminio/visual-semiotic-ai-analysis/label-studio-output/ | awk '{print $NF}'); do
|
|
if [[ "$file" != *.json ]]; then
|
|
mc mv "myminio/visual-semiotic-ai-analysis/label-studio-output/$file" \
|
|
"myminio/visual-semiotic-ai-analysis/label-studio-output/$file.json"
|
|
fi
|
|
done
|