Update nested_works_xml_upload.yml #3
This file contains hidden or 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: Upload Works TEI Files to S3 | |
| on: | |
| push: | |
| branches: | |
| - 'gaddel_development' | |
| paths: | |
| - 'works/tei/**/tei/*.xml' | |
| - '.github/workflows/nested_works_xml_upload.yml' | |
| permissions: | |
| id-token: write | |
| contents: read | |
| jobs: | |
| upload-works: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_SROPHE_ROLE }} | |
| aws-region: us-east-1 | |
| role-session-name: GitHub-OIDC-data | |
| role-duration-seconds: 14400 | |
| - name: Identify XML files | |
| # run: | | |
| # mkdir -p logs | |
| # find works/tei/*/tei -name '*.xml' > logs/xml_files.txt | |
| # echo "Processing $(wc -l < logs/xml_files.txt) XML files" | |
| # - name: Identify XML files | |
| run: | | |
| mkdir -p logs | |
| # Enable nullglob so the for loop doesn't break if no matches exist | |
| shopt -s nullglob | |
| for dir in works/tei/*/tei; do | |
| find "$dir" -type f -name '*.xml' | |
| done > logs/xml_files.txt | |
| count=$(wc -l < logs/xml_files.txt) | |
| echo "Found $count XML file(s) to upload." | |
| - name: Upload XML files to S3 | |
| run: | | |
| uploaded=0 | |
| while IFS= read -r file; do | |
| filename=$(basename "$file") | |
| echo "Uploading $file to s3://srophe-syriaca-front-end/work/$filename" | |
| if aws s3 cp "$file" "s3://srophe-syriaca-front-end/work/$filename"; then | |
| uploaded=$((uploaded + 1)) | |
| else | |
| echo "Failed to upload: $file" | |
| fi | |
| done < logs/xml_files.txt | |
| echo "Total files uploaded: $uploaded" |