-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
1 changed file
with
56 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: S3 and Drive CI/CD Pipeline | ||
on: | ||
push: | ||
branches: | ||
- feat/drive-to-s3 | ||
jobs: | ||
run-pipeline: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Print AWS Key (for debugging only) | ||
run: echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" | ||
|
||
- name: Install AWS CLI | ||
run: | | ||
sudo apt-get install awscli | ||
- name: Install gdrive CLI | ||
run: | | ||
curl -L -o gdrive.tar.gz https://github.com/prasmussen/gdrive/releases/download/2.1.0/gdrive-linux-x64 | ||
tar -xzf gdrive.tar.gz -C /usr/local/bin | ||
- name: Authenticate gdrive with service account | ||
run: | | ||
gdrive about --service-account <path-to-your-service-account-json> | ||
- name: Configure AWS credentials manually | ||
run: | | ||
aws configure set aws_access_key_id "${{ secrets.AWS_ACCESS_KEY_ID }}" | ||
aws configure set aws_secret_access_key "${{ secrets.AWS_SECRET_ACCESS_KEY }}" | ||
aws configure set region ap-south-1 | ||
- name: Rename folder in S3 to backup | ||
run: | | ||
aws s3 mv s3://isac-nitkkr-public/isaac-s3-images/ s3://isac-nitkkr-public/isaac-s3-images-bkp/ --recursive | ||
env: | ||
AWS_REGION: ap-south-1 | ||
|
||
- name: Download folder from Google Drive using gdrive | ||
run: | | ||
gdrive download --recursive 1YLdE1YjT1qSU8ank-ZVhYs5cl0jQohS8 | ||
- name: Upload folder to S3 | ||
run: | | ||
aws s3 cp /tmp/drive-folder s3://isac-nitkkr-public/isaac-s3-images/ --recursive | ||
env: | ||
AWS_REGION: ap-south-1 | ||
|
||
- name: Delete backup folder from S3 if all tasks pass | ||
if: ${{ success() }} | ||
run: | | ||
aws s3 rm s3://isac-nitkkr-public/isaac-s3-images-bkp/ --recursive | ||
env: | ||
AWS_REGION: ap-south-1 |