Skip to content

Commit 40d7134

Browse files
authored
ci(workflows): sync firstdata metadata to S3-compatible storage (MLT-OSS#17)
- add S3 env vars config from GitHub Secrets - configure AWS CLI for S3-compatible endpoint - sync firstdata/ to S3 bucket with optional --delete support
1 parent be0a2a5 commit 40d7134

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/update-indexes.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ jobs:
1212
runs-on: ubuntu-latest
1313
permissions:
1414
contents: write
15+
env:
16+
S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
17+
S3_SECRET_KEY: ${{ secrets.S3_SECRET_KEY }}
18+
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
19+
ENDPOINT_URL: ${{ secrets.ENDPOINT_URL }}
20+
ENABLE_DELETE: ${{ secrets.ENABLE_DELETE }}
21+
TARGET_PREFIX: firstdata/github/firstdata
1522
steps:
1623
- uses: actions/checkout@v4
1724

@@ -42,3 +49,25 @@ jobs:
4249
git add firstdata/indexes/ assets/badges/
4350
git diff --cached --quiet || git commit -m "chore(indexes): auto-update indexes"
4451
git push
52+
53+
- name: Configure AWS CLI for COS (S3 compatible)
54+
run: |
55+
aws configure set aws_access_key_id "$S3_ACCESS_KEY"
56+
aws configure set aws_secret_access_key "$S3_SECRET_KEY"
57+
aws configure set default.region "us-east-1"
58+
aws configure set default.s3.addressing_style virtual
59+
60+
- name: Sync firstdata folder to COS prefix
61+
run: |
62+
set -euo pipefail
63+
[ -n "${S3_BUCKET_NAME:-}" ] || { echo "S3_BUCKET_NAME is empty"; exit 1; }
64+
[ -n "${ENDPOINT_URL:-}" ] || { echo "ENDPOINT_URL is empty"; exit 1; }
65+
[ -n "${TARGET_PREFIX:-}" ] || { echo "TARGET_PREFIX is empty"; exit 1; }
66+
SYNC_ARGS=(--endpoint-url "$ENDPOINT_URL")
67+
68+
if [ "${ENABLE_DELETE:-false}" = "true" ]; then
69+
echo "ENABLE_DELETE=true, enabling --delete for sync."
70+
SYNC_ARGS+=(--delete)
71+
fi
72+
73+
aws s3 sync ./firstdata/ "s3://$S3_BUCKET_NAME/$TARGET_PREFIX/" "${SYNC_ARGS[@]}"

0 commit comments

Comments
 (0)