From 8d144e8a947308c94dd41f1b2bf37fe5b442f38c Mon Sep 17 00:00:00 2001 From: mhmdksh Date: Thu, 6 Jun 2024 16:20:01 +0400 Subject: [PATCH 1/4] Adding main branch and Pipelines for all environments --- .github/workflows/pipeline-develop.yml | 4 +-- .github/workflows/pipeline-main.yml | 25 +++++++++++++++++++ ...-devouch.yml => start-devouch-develop.yml} | 2 +- .github/workflows/start-devouch-main.yml | 21 ++++++++++++++++ ...p-devouch.yml => stop-devouch-develop.yml} | 2 +- .github/workflows/stop-devouch-main.yml | 24 ++++++++++++++++++ 6 files changed, 74 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/pipeline-main.yml rename .github/workflows/{start-devouch.yml => start-devouch-develop.yml} (93%) create mode 100644 .github/workflows/start-devouch-main.yml rename .github/workflows/{stop-devouch.yml => stop-devouch-develop.yml} (95%) create mode 100644 .github/workflows/stop-devouch-main.yml diff --git a/.github/workflows/pipeline-develop.yml b/.github/workflows/pipeline-develop.yml index 0c20062..8095e0a 100644 --- a/.github/workflows/pipeline-develop.yml +++ b/.github/workflows/pipeline-develop.yml @@ -5,8 +5,8 @@ on: - develop jobs: - build: - name: Build + deploy: + name: Deploy runs-on: ubuntu-latest steps: - name: Production Auto-Deploy diff --git a/.github/workflows/pipeline-main.yml b/.github/workflows/pipeline-main.yml new file mode 100644 index 0000000..8b7cf8a --- /dev/null +++ b/.github/workflows/pipeline-main.yml @@ -0,0 +1,25 @@ +name: auto-deploy-main +on: + push: + branches: + - main +jobs: + + deploy: + name: Deploy + runs-on: ubuntu-latest + steps: + - name: Production Auto-Deploy + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.PROD_HOST }} + username: ${{ secrets.PROD_USERNAME }} + key: ${{ secrets.PROD_PRIVATE_KEY }} + port: 22 + script: | + cd $HOME/DeVouch-BE + git checkout main + git checkout -- . + git pull + docker compose stop devouch squid-db + docker compose up -d --build \ No newline at end of file diff --git a/.github/workflows/start-devouch.yml b/.github/workflows/start-devouch-develop.yml similarity index 93% rename from .github/workflows/start-devouch.yml rename to .github/workflows/start-devouch-develop.yml index 762a6fa..ee1d60f 100644 --- a/.github/workflows/start-devouch.yml +++ b/.github/workflows/start-devouch-develop.yml @@ -1,4 +1,4 @@ -name: start-devouch +name: start-devouch-develop on: workflow_dispatch: diff --git a/.github/workflows/start-devouch-main.yml b/.github/workflows/start-devouch-main.yml new file mode 100644 index 0000000..431b73f --- /dev/null +++ b/.github/workflows/start-devouch-main.yml @@ -0,0 +1,21 @@ +name: start-devouch-main + +on: + workflow_dispatch: + +jobs: + + start: + name: Start Devouch + runs-on: ubuntu-latest + steps: + - name: Start Devouch + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.PROD_HOST }} + username: ${{ secrets.PROD_USERNAME }} + key: ${{ secrets.PROD_PRIVATE_KEY }} + port: 22 + script: | + cd $HOME/DeVouch-BE + docker compose up -d --build \ No newline at end of file diff --git a/.github/workflows/stop-devouch.yml b/.github/workflows/stop-devouch-develop.yml similarity index 95% rename from .github/workflows/stop-devouch.yml rename to .github/workflows/stop-devouch-develop.yml index bd89580..258bbd1 100644 --- a/.github/workflows/stop-devouch.yml +++ b/.github/workflows/stop-devouch-develop.yml @@ -1,4 +1,4 @@ -name: stop-devouch +name: stop-devouch-develop on: workflow_dispatch: diff --git a/.github/workflows/stop-devouch-main.yml b/.github/workflows/stop-devouch-main.yml new file mode 100644 index 0000000..7885c6e --- /dev/null +++ b/.github/workflows/stop-devouch-main.yml @@ -0,0 +1,24 @@ +name: stop-devouch-main + +on: + workflow_dispatch: + +jobs: + + stop: + name: Stop Devouch + runs-on: ubuntu-latest + steps: + - name: Stop Devouch + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.PROD_HOST }} + username: ${{ secrets.PROD_USERNAME }} + key: ${{ secrets.PROD_PRIVATE_KEY }} + port: 22 + script: | + cd $HOME/DeVouch-BE + docker compose stop devouch squid-db + docker compose rm -f -v devouch squid-db + docker rmi -f $(docker images | grep 'devouch' | awk '{print $3}') + docker volume rm $(docker volume ls | grep 'db-data' | awk '{print $2}') From 9a4c81996e465602ff751ea02e22617894692e9c Mon Sep 17 00:00:00 2001 From: Moe Shehab <52987806+mhmdksh@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:30:23 +0400 Subject: [PATCH 2/4] Update pipeline-develop.yml --- .github/workflows/pipeline-develop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline-develop.yml b/.github/workflows/pipeline-develop.yml index 8095e0a..c56d2b7 100644 --- a/.github/workflows/pipeline-develop.yml +++ b/.github/workflows/pipeline-develop.yml @@ -9,7 +9,7 @@ jobs: name: Deploy runs-on: ubuntu-latest steps: - - name: Production Auto-Deploy + - name: Staging Auto-Deploy uses: appleboy/ssh-action@v1.0.3 with: host: ${{ secrets.STAGING_HOST }} From 77ce63e21e2f968ba81ca5fb099e4ac9291128c1 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Thu, 6 Jun 2024 16:10:37 +0330 Subject: [PATCH 3/4] Changed attestorOrganiosation ID --- src/controllers/authorizeAttestation.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/authorizeAttestation.ts b/src/controllers/authorizeAttestation.ts index 1e69f9c..e036c81 100644 --- a/src/controllers/authorizeAttestation.ts +++ b/src/controllers/authorizeAttestation.ts @@ -15,8 +15,9 @@ export const handleAuthorize = async ( recipient, } = EASContract.events.Attested.decode(log); + const organisationId = schemaUid.toLocaleLowerCase(); const organisation = await ctx.store.findOneBy(Organisation, { - id: schemaUid.toLocaleLowerCase(), + id: organisationId, issuer: issuer.toLocaleLowerCase(), }); @@ -33,7 +34,7 @@ export const handleAuthorize = async ( const attestor = await getAttestor(ctx, accountAddress); - const key = uid.toLocaleLowerCase(); + const key = `${organisationId}-${accountAddress}`; let attestorOrganisation: AttestorOrganisation = new AttestorOrganisation({ id: key, From 6f88321a6a382a3368c9756601f7c4d458be7f55 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Thu, 6 Jun 2024 16:14:54 +0330 Subject: [PATCH 4/4] Revert "Changed attestorOrganiosation ID" This reverts commit 77ce63e21e2f968ba81ca5fb099e4ac9291128c1. --- src/controllers/authorizeAttestation.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/controllers/authorizeAttestation.ts b/src/controllers/authorizeAttestation.ts index e036c81..1e69f9c 100644 --- a/src/controllers/authorizeAttestation.ts +++ b/src/controllers/authorizeAttestation.ts @@ -15,9 +15,8 @@ export const handleAuthorize = async ( recipient, } = EASContract.events.Attested.decode(log); - const organisationId = schemaUid.toLocaleLowerCase(); const organisation = await ctx.store.findOneBy(Organisation, { - id: organisationId, + id: schemaUid.toLocaleLowerCase(), issuer: issuer.toLocaleLowerCase(), }); @@ -34,7 +33,7 @@ export const handleAuthorize = async ( const attestor = await getAttestor(ctx, accountAddress); - const key = `${organisationId}-${accountAddress}`; + const key = uid.toLocaleLowerCase(); let attestorOrganisation: AttestorOrganisation = new AttestorOrganisation({ id: key,