Skip to content

Commit

Permalink
new workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
krrish-sehgal committed Nov 24, 2024
1 parent 94a4e6f commit 0719560
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions .github/workflows/encrypt-and-upload-model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Model Upload with Versioning and Cleanup
on:
push:
paths:
- "models/**" # Trigger on changes in the 'models' directory
- "s3-uploads/**" # Trigger on changes in the 's3-uploads' directory
- "model_versions.json" # Trigger on changes in the version file

jobs:
Expand Down Expand Up @@ -43,6 +43,20 @@ jobs:
echo "changed_models=$CHANGED_MODELS" >> $GITHUB_ENV
- name: Upload private key to S3 (from s3-uploads folder)
run: |
PRIVATE_KEY_PATH="s3-uploads/private_key.pem" # Path of your private key in the s3-uploads folder
S3_BUCKET="${{ secrets.S3_BUCKET_NAME }}"
KMS_KEY_ID="${{ secrets.KMS_KEY_ID }}"
# Upload private key to S3 with encryption
echo "Uploading private key to S3..."
aws s3 cp "$PRIVATE_KEY_PATH" "s3://$S3_BUCKET/keys/private_key.pem" --sse aws:kms --sse-kms-key-id "$KMS_KEY_ID"
# After successful upload, delete the private key from the repository
echo "Deleting private key from the repository after uploading to S3..."
rm "$PRIVATE_KEY_PATH"
- name: Upload updated models
if: env.changed_models != ''
run: |
Expand All @@ -58,7 +72,7 @@ jobs:
fi
CURRENT_VERSION=$(jq -r --arg model "$MODEL" '.[$model]' <<< "$CURRENT_VERSIONS")
MODEL_PATH="models/$MODEL"
MODEL_PATH="s3-uploads/$MODEL"
S3_FILE="s3://$S3_BUCKET/${MODEL}-${CURRENT_VERSION}"
echo "Uploading $MODEL (version $CURRENT_VERSION) to $S3_FILE"
Expand All @@ -76,16 +90,19 @@ jobs:
fi
done
- name: Commit and push model deletions
- name: Empty the s3-uploads folder
if: env.changed_models != ''
run: |
echo "Cleaning up the s3-uploads folder..."
rm -rf s3-uploads/*
- name: Commit model deletions and changes
if: env.changed_models != ''
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git remote set-url origin https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git
# Add and commit changes (deleted models)
git add models/
git commit -m "Delete uploaded models from repository"
# Push changes back to the repository
git add -u
git commit -m "Delete uploaded models and private key from repository after S3 upload"
git push
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0719560

Please sign in to comment.