Skip to content

Commit

Permalink
Merge pull request #8 from aqeell7/implemented-ci-cd
Browse files Browse the repository at this point in the history
Implemented Continuous Integration and Deployment (CI/CD) Pipeline
  • Loading branch information
adithyaakrishna authored Nov 7, 2024
2 parents 5607c81 + 0953860 commit f9bcffb
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
72 changes: 72 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: CI/CD Pipeline

on:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 'current'

- name: Set commit message
run: echo "COMMIT_MESSAGE=$(git log -1 --pretty=%B)" >> $GITHUB_ENV

- name: Install dependencies
run: |
npm install
npm install koffi
- name: Run tests
if: ${{ !contains(env.COMMIT_MESSAGE, 'wip') && !contains(env.COMMIT_MESSAGE, 'docs') }}
run: |
npm run test || echo "Tests failed" && exit 1
- name: Cleanup
if: ${{ always() }}
run: |
echo "Cleaning up..."
deploy:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up AWS CLI
run: |
sudo apt-get update -y
sudo apt-get install zip -y
sudo apt-get install awscli -y
mkdir ~/.aws/
touch ~/.aws/credentials
printf "[default]\nregion=ap-south-1\naws_access_key_id = %s\naws_secret_access_key = %s\n" "${{ secrets.AWS_ACCESS_KEY_ID }}" "${{ secrets.AWS_SECRET_ACCESS_KEY }}" >> ~/.aws/credentials
touch ~/.aws/config
- name: Set up environment
run: |
echo -e "${{ secrets.ENV }}" > .env.production
- name: Create deployment package
run: |
export FILE=pkg-$(date +%s%N).zip
zip -r $FILE * .* -x '*.git*'
- name: Deploy to AWS
run: |
export BUCKET=elasticbeanstalk-ap-south-1-342772716647
export APP_NAME=reclaim-protocol
export ENV_NAME=witness
export VERSION=${{ github.sha }}
aws s3 cp $FILE s3://$BUCKET/$FILE
aws elasticbeanstalk create-application-version --application-name $APP_NAME --version-label $VERSION --source-bundle S3Bucket=$BUCKET,S3Key=$FILE
aws elasticbeanstalk update-environment --application-name $APP_NAME --environment-name $ENV_NAME --version-label $VERSION
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
</div>
</div>


![Test status](https://github.com/ReclaimProtocol/attestor-core/actions/workflows/ci-cd.yml/badge.svg?job=test)
![Deploy status](https://github.com/ReclaimProtocol/attestor-core/actions/workflows/ci-cd.yml/badge.svg?job=deploy)

## What is the Reclaim Protocol?

Reclaim enables you to bring user activity, reputation, and identity from external websites into your own platform.
Expand Down Expand Up @@ -88,4 +92,4 @@ For Indie Hackers: [Check out our guidelines and potential grant opportunities](

This project is licensed under a [AGPL v3](./LICENSE). By contributing to this project, you agree that your contributions will be licensed under its terms.

Thank you for your contributions!
Thank you for your contributions!

0 comments on commit f9bcffb

Please sign in to comment.