Skip to content

Commit

Permalink
Merge pull request #17 from Giveth/staging
Browse files Browse the repository at this point in the history
Release: Gitcoin Support
  • Loading branch information
CarlosQ96 authored Jul 17, 2023
2 parents 59e13ab + 41fe6fb commit 26ab741
Show file tree
Hide file tree
Showing 31 changed files with 8,498 additions and 15,559 deletions.
45 changes: 22 additions & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
module.exports ={
"env": {
"browser": true,
"es2021": true,
"node": true
module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2021,
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"no-prototype-builtins":"warn",
"no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars":"warn",
"@typescript-eslint/consistent-type-definitions":"off",
"@typescript-eslint/no-var-requires":"warn"
}
}
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'no-prototype-builtins': 'warn',
'no-unused-vars': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-var-requires': 'warn',
'prettier/prettier': ['error', { singleQuote: true }],
},
};
20 changes: 14 additions & 6 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
- 5444:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
Expand All @@ -45,8 +45,9 @@ jobs:
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:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging'
Expand Down Expand Up @@ -74,15 +75,23 @@ jobs:
needs: publish
runs-on: ubuntu-latest
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 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 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]
Expand All @@ -91,4 +100,3 @@ jobs:
host: ${{ secrets.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USERNAME }}
privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}}

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ coverage
.cache

config/development.env
config/develop.env
config/staging.env
.vscode/settings.json

*.rdb
Expand Down
6 changes: 6 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extension": ["ts"],
"timeout": 30000,
"exit": true,
"require": ["ts-node/register", "tsconfig-paths/register"]
}
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Sign in with Ethereum
Reference implementation for use with Giveth.io
### Build Status:
- Develop - [![CI/CD](https://github.com/Giveth/SiweAuthMicroservice/actions/workflows/CI-CD.yml/badge.svg?branch=develop)](https://github.com/Giveth/SiweAuthMicroservice/actions/workflows/CI-CD.yml)
- Staging - [![CI/CD](https://github.com/Giveth/SiweAuthMicroservice/actions/workflows/CI-CD.yml/badge.svg?branch=staging)](https://github.com/Giveth/SiweAuthMicroservice/actions/workflows/CI-CD.yml)
- Production - [![CI/CD](https://github.com/Giveth/SiweAuthMicroservice/actions/workflows/CI-CD.yml/badge.svg?branch=main)](https://github.com/Giveth/SiweAuthMicroservice/actions/workflows/CI-CD.yml)
---
## References
I used these articles for writing project

Expand All @@ -18,11 +25,12 @@ typeorm migration:create ./migrations/createAccessTokenTable
#### Then you need to run the migrations like so:

```
npm run typeorm:cli -- migration:run
npm run db:migrate:run:local
```

#### If you want to revert last migration :

```
npm run typeorm:cli -- migration:revert
npm run db:migrate:revert:local
```
21 changes: 19 additions & 2 deletions config/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
PORT=3000

TYPEORM_DATABASE_NAME=siwe_microservice
TYPEORM_DATABASE_NAME=microservices
TYPEORM_DATABASE_USER=postgres
TYPEORM_DATABASE_PASSWORD=postgres
TYPEORM_DATABASE_HOST=127.0.0.1
TYPEORM_DATABASE_PORT=5443

JWT_SECRET=fdksjalkfhjio472389roiewfhskjahfjka
ACCESS_TOKEN_LIFETIME_HOURS=2
ACCESS_TOKEN_LIFETIME_HOURS=2000

BCRYPT_SALT=$2b$10$MSIRw14eVDzxdztX3AZYlu
PRIVATE_ETHERS_TEST_KEY=8ab0e165c2ea461b01cdd49aec882d179dccdbdb5c85c3f9c94c448aa65c5ace
PUBLIC_ETHERS_TEST_KEY=0x53bFf74b9Af2E3853f758A8D2Bd61CD115d27782

HOSTNAME_WHITELIST=localhost, loca.lt

NONCE_LIFE_MINUTES=5

# The following are used for the sending logs to elasticsearch
ENABLE_ELASTICSEARCH_LOG=
ELASTICSEARCH_HOST=
ELATICSEARCH_AUTH=

# Following are for GitCoin Passport
GITCOIN_API_KEY=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
GITCOIN_COMMUNITY_ID=0
8 changes: 6 additions & 2 deletions config/test.env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
PORT=3001
PORT=3089

TYPEORM_DATABASE_NAME=microservices
TYPEORM_DATABASE_USER=postgres
TYPEORM_DATABASE_PASSWORD=postgres
TYPEORM_DATABASE_HOST=localhost
TYPEORM_DATABASE_PORT=5432
TYPEORM_DATABASE_PORT=5444

JWT_SECRET=fdksjalkfhjio472389roiewfhskjahfjka
ACCESS_TOKEN_LIFETIME_HOURS=2
Expand All @@ -14,3 +14,7 @@ PRIVATE_ETHERS_TEST_KEY=8ab0e165c2ea461b01cdd49aec882d179dccdbdb5c85c3f9c94c448a
PUBLIC_ETHERS_TEST_KEY=0x53bFf74b9Af2E3853f758A8D2Bd61CD115d27782

HOSTNAME_WHITELIST=localhost, loca.lt

NONCE_LIFE_MINUTES=5

REDIS_PORT=6489
44 changes: 44 additions & 0 deletions docker-compose-develop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '3.3'

services:
siwe-microservice:
#see https://github.com/docker/build-push-action/tree/releases/v1#tag_with_ref

# is sometime you want to rollback you can change the tag manually in server( not commit to git)
# from master to your desired commit hash and the run command:
# 1. docker-compose -f docker-compose-develop.yml pull
# 2. docker-compose -f docker-compose-develop.yml down
# 3. docker-compose -f docker-compose-develop.yml up -d
image: ghcr.io/giveth/siweauthmicroservice:develop
restart: always
command: npm run start:server:develop
environment:
- NODE_ENV=develop
volumes:
# You should have a develop.env file in the config folder
- type: bind
source: ./config
target: /usr/src/app/dist/config
- type: bind
source: ./config
target: /usr/src/app/config
- type: bind
source: ./logs
target: /usr/src/app/dist/logs
ports:
- "3000:3000"



redis-siwe-microservice:
# it's better to not using latest tag, maybe latest tag have some breaking changes
image: bitnami/redis:5.0.9-debian-10-r142
container_name: redis-siwe-microservice
environment:
- ALLOW_EMPTY_PASSWORD=yes
restart: always
volumes:
- redis-siwe-microservice-data:/bitnami/redis/data

volumes:
redis-siwe-microservice-data:
Loading

0 comments on commit 26ab741

Please sign in to comment.