-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5b97e8
commit cfc90bf
Showing
11 changed files
with
115 additions
and
47 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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
name: Model Upload with SSE-KMS | ||
name: Model Upload with Versioning and Cleanup | ||
|
||
on: | ||
push: | ||
paths: | ||
- "models/**" # Trigger on any file changes in the 'models' directory | ||
- "models/**" # Trigger on changes in the 'models' directory | ||
- "model_versions.json" # Trigger on changes in the version file | ||
|
||
jobs: | ||
upload_model: | ||
|
@@ -16,32 +17,66 @@ jobs: | |
- name: Set up AWS CLI | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} # Securely use the secret key | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} # Securely use the secret key | ||
aws-region: ${{ secrets.AWS_REGION }} # Use the region stored in the secret | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Find model files | ||
id: find_models | ||
- name: Compare model versions | ||
id: compare_versions | ||
run: | | ||
# Find all model files in the models directory | ||
MODEL_FILES=$(find models -type f) | ||
echo "Model files found: $MODEL_FILES" | ||
echo "::set-output name=model_files::$MODEL_FILES" | ||
# Read the current and previous model versions | ||
CURRENT_VERSIONS=$(cat model_versions.json) | ||
S3_BUCKET="${{ secrets.S3_BUCKET_NAME }}" | ||
CHANGED_MODELS="" | ||
for MODEL in $(jq -r 'keys[]' <<< "$CURRENT_VERSIONS"); do | ||
CURRENT_VERSION=$(jq -r --arg model "$MODEL" '.[$model]' <<< "$CURRENT_VERSIONS") | ||
S3_FILE="s3://$S3_BUCKET/${MODEL}-${CURRENT_VERSION}" | ||
# Check if the model with the current version already exists in S3 | ||
if ! aws s3 ls "$S3_FILE" >/dev/null 2>&1; then | ||
echo "New or updated model detected: $MODEL (version $CURRENT_VERSION)" | ||
CHANGED_MODELS="$CHANGED_MODELS $MODEL" | ||
fi | ||
done | ||
echo "::set-output name=changed_models::$CHANGED_MODELS" | ||
- name: Upload Models to S3 with SSE-KMS | ||
- name: Upload updated models | ||
if: steps.compare_versions.outputs.changed_models != '' | ||
run: | | ||
# Variables | ||
S3_BUCKET_NAME="${{ secrets.S3_BUCKET_NAME }}" # Use the secret for the bucket name | ||
KMS_KEY_ID="${{ secrets.KMS_KEY_ID }}" # Use the secret for the KMS key ID | ||
MODEL_FILES="${{ steps.find_models.outputs.model_files }}" # List of model files | ||
CHANGED_MODELS="${{ steps.compare_versions.outputs.changed_models }}" | ||
CURRENT_VERSIONS=$(cat model_versions.json) | ||
S3_BUCKET="${{ secrets.S3_BUCKET_NAME }}" | ||
KMS_KEY_ID="${{ secrets.KMS_KEY_ID }}" | ||
# Loop over each model file | ||
for MODEL_FILE in $MODEL_FILES | ||
do | ||
echo "Uploading model file to S3 with SSE-KMS: $MODEL_FILE" | ||
for MODEL in $CHANGED_MODELS; do | ||
CURRENT_VERSION=$(jq -r --arg model "$MODEL" '.[$model]' <<< "$CURRENT_VERSIONS") | ||
MODEL_PATH="models/$MODEL" | ||
S3_FILE="s3://$S3_BUCKET/${MODEL}-${CURRENT_VERSION}" | ||
# Upload the model file directly to S3 with server-side encryption using KMS | ||
aws s3 cp $MODEL_FILE s3://$S3_BUCKET_NAME/ --sse aws:kms --sse-kms-key-id $KMS_KEY_ID | ||
echo "Uploading $MODEL (version $CURRENT_VERSION) to $S3_FILE" | ||
echo "Model file uploaded successfully: $MODEL_FILE" | ||
# Upload to S3 with SSE-KMS | ||
aws s3 cp "$MODEL_PATH" "$S3_FILE" --sse aws:kms --sse-kms-key-id "$KMS_KEY_ID" | ||
# Check if upload was successful, then delete the file from the repo | ||
if [ $? -eq 0 ]; then | ||
echo "Model uploaded successfully, deleting $MODEL from the repository." | ||
rm "$MODEL_PATH" | ||
else | ||
echo "Model upload failed for $MODEL." | ||
fi | ||
done | ||
- name: Commit model deletions | ||
if: steps.compare_versions.outputs.changed_models != '' | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
# Stage deleted files and commit the changes | ||
git add -u | ||
git commit -m "Delete updated models from repo after S3 upload" | ||
git push |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
node_modules | ||
.env | ||
.env | ||
Model |
File renamed without changes.
Binary file not shown.
Submodule medium_posts
deleted from
ca1378
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
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
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,5 @@ | ||
{ | ||
"antispofing.onnx": "1.0.0", | ||
"face_recognition.onnx": "1.0.0" | ||
} | ||
|
Binary file not shown.
Binary file not shown.