Skip to content

Commit

Permalink
Merge pull request #25 from Giveth/staging
Browse files Browse the repository at this point in the history
Multi sig release, 2023-12-31
  • Loading branch information
mohammadranjbarz authored Jan 1, 2024
2 parents 26ab741 + a3d8574 commit 3a50e12
Show file tree
Hide file tree
Showing 33 changed files with 4,041 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: CI/CD
name: develop-pipeline

on: [push]
on:
push:
branches:
- develop

pull_request:
branches:
- develop

jobs:
test:
Expand Down Expand Up @@ -50,9 +57,9 @@ jobs:
GITCOIN_COMMUNITY_ID: ${{ secrets.GITCOIN_COMMUNITY_ID }}

publish:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging'
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- name: Check out the repo
uses: actions/checkout@v2
Expand All @@ -69,34 +76,15 @@ jobs:
# 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
if: github.event_name == 'push'
steps:
- name: Develop deploy
if: github.ref == 'refs/heads/develop'
uses: garygrossgarten/[email protected]
with:
command: cd SiweAuthMicroservice && 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: Staging deploy
if: github.ref == 'refs/heads/staging'
uses: garygrossgarten/[email protected]
with:
command: cd SiweAuthMicroservice && git checkout staging && git fetch && git reset --hard origin/staging && 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: Production deploy
if: github.ref == 'refs/heads/main'
uses: garygrossgarten/[email protected]
with:
command: cd SiweAuthMicroservice && 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}}
94 changes: 94 additions & 0 deletions .github/workflows/main-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: main-pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6489:6379
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: microservices
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5444:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.14.2
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run migrations
run: npm run db:migrate:run:test
- name: Run tests
run: npm run test
env:
GITCOIN_API_KEY: ${{ secrets.GITCOIN_API_KEY }}
GITCOIN_COMMUNITY_ID: ${{ secrets.GITCOIN_COMMUNITY_ID }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
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/siweauthmicroservice
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:
needs: publish
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
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 auth
docker compose pull auth
docker compose up -d auth
docker image prune -a --force
94 changes: 94 additions & 0 deletions .github/workflows/staging-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: staging-pipeline

on:
push:
branches:
- staging
pull_request:
branches:
- staging

jobs:
test:
runs-on: ubuntu-latest
services:
# Label used to access the service container
redis:
# Docker Hub image
image: redis
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6489:6379
postgres:
image: postgres:14
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: microservices
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5444:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16.14.2
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run migrations
run: npm run db:migrate:run:test
- name: Run tests
run: npm run test
env:
GITCOIN_API_KEY: ${{ secrets.GITCOIN_API_KEY }}
GITCOIN_COMMUNITY_ID: ${{ secrets.GITCOIN_COMMUNITY_ID }}

publish:
needs: test
runs-on: ubuntu-latest
if: github.event_name == 'push'
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/siweauthmicroservice
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:
needs: publish
runs-on: ubuntu-latest
steps:
- name: SSH and Redeploy
uses: appleboy/[email protected]
with:
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 auth
docker-compose pull auth
docker-compose up -d auth
docker image prune -a --force
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.14.2
2 changes: 2 additions & 0 deletions config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ TYPEORM_DATABASE_USER=postgres
TYPEORM_DATABASE_PASSWORD=postgres
TYPEORM_DATABASE_HOST=127.0.0.1
TYPEORM_DATABASE_PORT=5443
# Handle as local, develop, staging, production
ENVIRONMENT=local

JWT_SECRET=fdksjalkfhjio472389roiewfhskjahfjka
ACCESS_TOKEN_LIFETIME_HOURS=2000
Expand Down
3 changes: 3 additions & 0 deletions config/test.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ BCRYPT_SALT=$2b$10$MSIRw14eVDzxdztX3AZYlu
PRIVATE_ETHERS_TEST_KEY=8ab0e165c2ea461b01cdd49aec882d179dccdbdb5c85c3f9c94c448aa65c5ace
PUBLIC_ETHERS_TEST_KEY=0x53bFf74b9Af2E3853f758A8D2Bd61CD115d27782

PRIVATE_SOLANA_TEST_KEY=4ncZsCpjpVgyp9tRowQNost352WS4EQnuAFvWXHUE3XcasnuyiTwwSrdnixf4Sves8x1zzNhdrHJVYXdBdnfDiKx
PUBLIC_SOLANA_TEST_KEY=ALuY9D3XDhNgJvKQavNcLS6qZ9oGP4mUWRvnerWXxgML

HOSTNAME_WHITELIST=localhost, loca.lt

NONCE_LIFE_MINUTES=5
Expand Down
75 changes: 75 additions & 0 deletions migrations/1694633909572-AddMultisigSessionEntity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class AddMultisigSessionEntity1694633909572
implements MigrationInterface
{
name = 'AddMultisigSessionEntity1694633909572';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'multisig_session',
columns: [
{
name: 'id',
type: 'int',
isPrimary: true,
isGenerated: true,
generationStrategy: 'increment',
},
{
name: 'multisigAddress',
type: 'varchar',
isNullable: true,
},
{
name: 'safeTransactionMessage',
type: 'varchar',
isNullable: false,
},
{
name: 'safeTransactionHash',
type: 'varchar',
isNullable: true,
},
{
name: 'network',
type: 'int',
},
{
name: 'active',
type: 'boolean',
default: true,
},
{
name: 'expirationDate',
type: 'timestamp',
},
{
name: 'createdAt',
type: 'timestamp',
default: 'CURRENT_TIMESTAMP',
},
{
name: 'updatedAt',
type: 'timestamp',
default: 'CURRENT_TIMESTAMP',
},
],
indices: [
{
columnNames: ['multisigAddress'],
},
{
columnNames: ['network'],
},
],
}),
true,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('multisig_session');
}
}
Loading

0 comments on commit 3a50e12

Please sign in to comment.