From 4e4a68631d4fe53d866c96b0e46e42b7a0b2cb0a Mon Sep 17 00:00:00 2001 From: sahi-oro Date: Fri, 6 Sep 2024 17:46:54 +0530 Subject: [PATCH] added a cicd --- .github/workflows/s.yml | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/s.yml diff --git a/.github/workflows/s.yml b/.github/workflows/s.yml new file mode 100644 index 00000000..4b094e6c --- /dev/null +++ b/.github/workflows/s.yml @@ -0,0 +1,61 @@ +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 and unzip + run: | + sudo apt-get update + sudo apt-get install awscli unzip wget + + - 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 File from Google Drive + run: | + wget --no-check-certificate 'https://drive.google.com/uc?export=download&id=1YLdE1YjT1qSU8ank-ZVhYs5cl0jQohS8?usp=sharing' -O /tmp/file.zip + + - name: Verify Download + run: | + ls -l /tmp/ + if [ -f /tmp/file.zip ]; then echo "File exists."; else echo "File not found."; exit 1; fi + + - name: Check File Type + run: | + file /tmp/file.zip + + - name: Unzip downloaded file + run: | + unzip /tmp/file.zip -d /tmp/unzipped_files + + - name: Upload unzipped files to S3 + run: | + aws s3 cp /tmp/unzipped_files/ 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