From be509d9806bd53effedb10bd8ec3357041d99126 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Sun, 13 Aug 2023 12:53:18 +0330 Subject: [PATCH 1/7] Update CI-CD.yml --- .github/workflows/CI-CD.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI-CD.yml b/.github/workflows/CI-CD.yml index cc37dd0..214a47a 100644 --- a/.github/workflows/CI-CD.yml +++ b/.github/workflows/CI-CD.yml @@ -1,6 +1,10 @@ name: CI/CD -on: [push] +on: + push: + branches: + - staging + - main jobs: publish: From da13303d7d83f125d2514bbccd1859f9fbad7459 Mon Sep 17 00:00:00 2001 From: mhmdksh Date: Wed, 16 Aug 2023 12:41:32 +0300 Subject: [PATCH 2/7] Adding the main and staging pipelines to work on PR merges --- .github/workflows/CI-CD.yml | 60 -------------------------- .github/workflows/main-pipeline.yml | 45 +++++++++++++++++++ .github/workflows/staging-pipeline.yml | 45 +++++++++++++++++++ 3 files changed, 90 insertions(+), 60 deletions(-) delete mode 100644 .github/workflows/CI-CD.yml create mode 100644 .github/workflows/main-pipeline.yml create mode 100644 .github/workflows/staging-pipeline.yml diff --git a/.github/workflows/CI-CD.yml b/.github/workflows/CI-CD.yml deleted file mode 100644 index 214a47a..0000000 --- a/.github/workflows/CI-CD.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: CI/CD - -on: - push: - branches: - - staging - - main - -jobs: - publish: - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' - runs-on: ubuntu-latest - steps: - - name: Check out the repo - uses: actions/checkout@v2 - - name: Build image and push to GitHub Packages - uses: docker/build-push-action@v1 - with: - username: ${{ github.actor }} - password: ${{ github.token }} - registry: ghcr.io - repository: giveth/giveconomy-notification-service - add_git_labels: true - # Add branch name to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref} - tag_with_ref: true - # Add commit hash to docker image tag @see{@link https://github.com/docker/build-push-action/tree/releases/v1#tag_with_sha} - tag_with_sha: true - - - deploy: - if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'|| github.ref == 'refs/heads/staging' - needs: publish - runs-on: ubuntu-latest - steps: - - name: Staging deploy - if: github.ref == 'refs/heads/staging' - uses: garygrossgarten/github-action-ssh@v0.6.4 - with: - command: cd giveconomy-notification-service && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a --force; - host: ${{ secrets.STAGING_HOST }} - username: ${{ secrets.STAGING_USERNAME }} - privateKey: ${{ secrets.STAGING_PRIVATE_KEY}} - - - name: Develop deploy - if: github.ref == 'refs/heads/develop' - uses: garygrossgarten/github-action-ssh@v0.6.4 - with: - command: cd giveconomy-notification-service && git checkout develop && git pull && docker-compose -f docker-compose-develop.yml pull && docker-compose -f docker-compose-develop.yml down && docker-compose -f docker-compose-develop.yml up -d && docker image prune -a --force; - host: ${{ secrets.DEVELOP_HOST }} - username: ${{ secrets.DEVELOP_USERNAME }} - privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}} - - - name: Production deploy - if: github.ref == 'refs/heads/main' - uses: garygrossgarten/github-action-ssh@v0.6.4 - with: - command: cd giveconomy-notification-service && git checkout main && git pull && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force; - host: ${{ secrets.PRODUCTION_HOST }} - username: ${{ secrets.PRODUCTION_USERNAME }} - privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}} diff --git a/.github/workflows/main-pipeline.yml b/.github/workflows/main-pipeline.yml new file mode 100644 index 0000000..19b6307 --- /dev/null +++ b/.github/workflows/main-pipeline.yml @@ -0,0 +1,45 @@ +name: ci-main + +on: + pull_request: + types: [closed] + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/giveth/giveconomy-notification-service:main + + deploy: + if: github.event.pull_request.merged == true + needs: publish + runs-on: ubuntu-latest + steps: + - name: Production deploy + uses: garygrossgarten/github-action-ssh@v0.6.4 + with: + command: cd giveconomy-notification-service && git checkout main && git pull && docker-compose -f docker-compose-production.yml +pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune +-a --force; + host: ${{ secrets.PRODUCTION_HOST }} + username: ${{ secrets.PRODUCTION_USERNAME }} + privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}} diff --git a/.github/workflows/staging-pipeline.yml b/.github/workflows/staging-pipeline.yml new file mode 100644 index 0000000..742be81 --- /dev/null +++ b/.github/workflows/staging-pipeline.yml @@ -0,0 +1,45 @@ +name: ci-staging + +on: + pull_request: + types: [closed] + branches: + - staging + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ghcr.io/giveth/giveconomy-notification-service:staging + + deploy: + if: github.event.pull_request.merged == true + needs: publish + runs-on: ubuntu-latest + steps: + - name: Staging deploy + uses: garygrossgarten/github-action-ssh@v0.6.4 + with: + command: cd giveconomy-notification-service && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml +pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a +--force; + host: ${{ secrets.STAGING_HOST }} + username: ${{ secrets.STAGING_USERNAME }} + privateKey: ${{ secrets.STAGING_PRIVATE_KEY}} From 24957098cdacb7f7729544e186cdc478445fed8f Mon Sep 17 00:00:00 2001 From: mhmdksh Date: Wed, 16 Aug 2023 12:55:04 +0300 Subject: [PATCH 3/7] Fixed Lint errors --- .github/workflows/main-pipeline.yml | 6 ++---- .github/workflows/staging-pipeline.yml | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main-pipeline.yml b/.github/workflows/main-pipeline.yml index 19b6307..4ec3463 100644 --- a/.github/workflows/main-pipeline.yml +++ b/.github/workflows/main-pipeline.yml @@ -37,9 +37,7 @@ jobs: - name: Production deploy uses: garygrossgarten/github-action-ssh@v0.6.4 with: - command: cd giveconomy-notification-service && git checkout main && git pull && docker-compose -f docker-compose-production.yml -pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune --a --force; + command: cd giveconomy-notification-service && git checkout main && git pull && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force; host: ${{ secrets.PRODUCTION_HOST }} username: ${{ secrets.PRODUCTION_USERNAME }} - privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}} + privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}} \ No newline at end of file diff --git a/.github/workflows/staging-pipeline.yml b/.github/workflows/staging-pipeline.yml index 742be81..3a03de5 100644 --- a/.github/workflows/staging-pipeline.yml +++ b/.github/workflows/staging-pipeline.yml @@ -37,9 +37,7 @@ jobs: - name: Staging deploy uses: garygrossgarten/github-action-ssh@v0.6.4 with: - command: cd giveconomy-notification-service && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml -pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a ---force; + command: cd giveconomy-notification-service && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a --force; host: ${{ secrets.STAGING_HOST }} username: ${{ secrets.STAGING_USERNAME }} - privateKey: ${{ secrets.STAGING_PRIVATE_KEY}} + privateKey: ${{ secrets.STAGING_PRIVATE_KEY}} \ No newline at end of file From 55ea0bbf004212077e5456aa451ce6d59f03efe2 Mon Sep 17 00:00:00 2001 From: Moe Shehab <52987806+mhmdksh@users.noreply.github.com> Date: Thu, 24 Aug 2023 19:49:46 +0400 Subject: [PATCH 4/7] Update staging-pipeline.yml --- .github/workflows/staging-pipeline.yml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/staging-pipeline.yml b/.github/workflows/staging-pipeline.yml index 3a03de5..041149d 100644 --- a/.github/workflows/staging-pipeline.yml +++ b/.github/workflows/staging-pipeline.yml @@ -30,14 +30,19 @@ jobs: tags: ghcr.io/giveth/giveconomy-notification-service:staging deploy: - if: github.event.pull_request.merged == true needs: publish runs-on: ubuntu-latest steps: - - name: Staging deploy - uses: garygrossgarten/github-action-ssh@v0.6.4 + - name: SSH and Redeploy + uses: appleboy/ssh-action@v1.0.0 with: - command: cd giveconomy-notification-service && git checkout staging && git pull && docker-compose -f docker-compose-staging.yml pull && docker-compose -f docker-compose-staging.yml down && docker-compose -f docker-compose-staging.yml up -d && docker image prune -a --force; - host: ${{ secrets.STAGING_HOST }} - username: ${{ secrets.STAGING_USERNAME }} - privateKey: ${{ secrets.STAGING_PRIVATE_KEY}} \ No newline at end of file + host: ${{ secrets.STAGING_HOST_ALL }} + username: ${{ secrets.STAGING_USERNAME_ALL }} + key: ${{ secrets.STAGING_PRIVATE_KEY_ALL }} + port: ${{ secrets.SSH_PORT }} + script: | + cd giveth-all + docker-compose stop givEconomy-notification-service + docker-compose pull givEconomy-notification-service + docker-compose up -d givEconomy-notification-service + docker image prune -a --force From b44bd096227e9a1177fcad767c6fd7047fde8dcf Mon Sep 17 00:00:00 2001 From: Moe Shehab <52987806+mhmdksh@users.noreply.github.com> Date: Thu, 24 Aug 2023 19:55:05 +0400 Subject: [PATCH 5/7] Update staging-pipeline.yml --- .github/workflows/staging-pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/staging-pipeline.yml b/.github/workflows/staging-pipeline.yml index 041149d..4813157 100644 --- a/.github/workflows/staging-pipeline.yml +++ b/.github/workflows/staging-pipeline.yml @@ -5,6 +5,7 @@ on: types: [closed] branches: - staging + workflow_dispatch: jobs: publish: From 217c4c8ba73493863f5f6e689bb6d9ab33ceabc4 Mon Sep 17 00:00:00 2001 From: Amin Latifi Date: Wed, 13 Sep 2023 16:14:51 +0330 Subject: [PATCH 6/7] Added production optimism givpower --- monitorConfig/production.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monitorConfig/production.ts b/monitorConfig/production.ts index 24e7831..73d717d 100644 --- a/monitorConfig/production.ts +++ b/monitorConfig/production.ts @@ -36,6 +36,12 @@ export const config: Config = { pollTimeMS: Number(process.env.OPTIMISM_POLL_TIME) || 30_000, // 30 Seconds maxFetchBlockRange: 1_000, contracts: [ + { + address: '0x301C739CF6bfb6B47A74878BdEB13f92F13Ae5E7', + title: 'Optimism GIVPower', + startBlock: 108350094, + type: ContractType.GIVpower, + }, { address: '0xE3Ac7b3e6B4065f4765d76fDC215606483BF3bD1', title: 'Optimism Token Distro', From c9b8a9cafb0acb310c20031d29e4993d44212ae9 Mon Sep 17 00:00:00 2001 From: Moe Shehab <52987806+mhmdksh@users.noreply.github.com> Date: Tue, 26 Dec 2023 17:14:45 +0400 Subject: [PATCH 7/7] Update main-pipeline.yml --- .github/workflows/main-pipeline.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main-pipeline.yml b/.github/workflows/main-pipeline.yml index 4ec3463..4b9c898 100644 --- a/.github/workflows/main-pipeline.yml +++ b/.github/workflows/main-pipeline.yml @@ -5,6 +5,7 @@ on: types: [closed] branches: - main + workflow_dispatch: jobs: publish: @@ -34,10 +35,16 @@ jobs: needs: publish runs-on: ubuntu-latest steps: - - name: Production deploy - uses: garygrossgarten/github-action-ssh@v0.6.4 + - name: SSH and Redeploy + uses: appleboy/ssh-action@v1.0.0 with: - command: cd giveconomy-notification-service && git checkout main && git pull && docker-compose -f docker-compose-production.yml pull && docker-compose -f docker-compose-production.yml down && docker-compose -f docker-compose-production.yml up -d && docker image prune -a --force; - host: ${{ secrets.PRODUCTION_HOST }} - username: ${{ secrets.PRODUCTION_USERNAME }} - privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}} \ No newline at end of file + host: ${{ secrets.PROD_HOST_ALL }} + username: ${{ secrets.PROD_USERNAME_ALL }} + key: ${{ secrets.PROD_PRIVATE_KEY_ALL }} + port: ${{ secrets.SSH_PORT }} + script: | + cd giveth-all + docker-compose stop givEconomy-notification-service + docker-compose pull givEconomy-notification-service + docker-compose up -d givEconomy-notification-service + docker image prune -a --force