-
Notifications
You must be signed in to change notification settings - Fork 18
73 lines (60 loc) · 2.19 KB
/
Copy pathnested_works_xml_upload.yml
File metadata and controls
73 lines (60 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Upload Works TEI Files to S3
on:
push:
branches:
- 'gaddel_development'
paths:
- 'works/tei/**/tei/*.xml'
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
# Optional: for full data upload
# - name: Identify XML files
# run: |
# mkdir -p logs
# find ./data/works/tei -type f -path '*/tei/*.xml' > logs/xml_files.txt
# count=$(wc -l < logs/xml_files.txt)
# echo "Found $count XML file(s) to upload."
- name: Identify updated XML files
id: files
run: |
echo "Fetching full commit history..."
git fetch --unshallow || echo "Already unshallowed."
echo "Looking for added/modified XML files under .data/works/tei/**/tei/"
UPDATED_FILES=$(git diff --name-only --diff-filter=AM origin/${{ github.event.before }} HEAD | grep '^\.data/works/tei/.*/tei/.*\.xml$' || true)
if [ -z "$UPDATED_FILES" ]; then
echo "No updated XML files in .data/works/tei/**/tei/"
exit 0
fi
mkdir -p logs
echo "$UPDATED_FILES" > xml_files.txt
COUNT=$(wc -l < logs/xml_files.txt)
echo "Found $COUNT updated XML files"
- 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 < xml_files.txt
echo "Total files uploaded: $uploaded"