Skip to content

Wallet processor check with lowercase address #176

Wallet processor check with lowercase address

Wallet processor check with lowercase address #176

name: Open State CI/CD
on:
push:
branches:
- '*'
release:
types: [published]
env:
IMAGE_TAG: latest
jobs:
tests:
name: Run tests
runs-on: ubuntu-latest
continue-on-error: false
services:
mongodb:
image: mongo:4.4.0
ports:
- 27017:27017
env:
MONGO_INITDB_ROOT_USERNAME: open_state
MONGO_INITDB_ROOT_PASSWORD: open_state
MONGO_INITDB_DATABASE: open_state
redis:
image: redis:6.0.7
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Prepare Java SDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Execute tests
run: ./gradlew check
- name: Save test results
uses: actions/upload-artifact@v2
with:
name: test_results_${{ github.sha }}
path: build/reports/tests/test/**
- name: Execute test coverage report
run: ./gradlew jacocoTestReport
- name: Save test coverage results
uses: actions/upload-artifact@v2
with:
name: test_coverage_results_${{ github.sha }}
path: build/reports/jacoco/test/html/**
build:
name: Build project
runs-on: ubuntu-latest
continue-on-error: false
needs: [tests]
if: github.event.action == 'published'
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Prepare Java SDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Build project
run: ./gradlew assemble
- name: Save executables
uses: actions/upload-artifact@v2
with:
name: assembles_${{ github.sha }}
path: build/libs/*.jar
package:
name: Packaging
runs-on: ubuntu-latest
continue-on-error: false
needs: [tests, build]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: assembles_${{ github.sha }}
path: build/libs
- name: Define image tag
run:
if [[ ${{ github.ref }} == refs/heads/master || ${{ github.ref }} == refs/heads/2.x.x-REACTIVE ]]; then export IMAGE_TAG=latest; else export IMAGE_TAG=${{ github.ref }}#refs/heads/; fi;
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER_NAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: openplatform/open-state:${{ env.IMAGE_TAG }}
file: docker/Dockerfile
deploy-production:
name: Deploy Production
runs-on: ubuntu-latest
continue-on-error: false
needs: [tests, build, package]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Deploy server
run: |
sudo apt install openssh-client
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
eval $(ssh-agent -s)
echo "${{ secrets.PROD_DEPLOY_SSH_KEY }}" | tr -d '\r' | ssh-add - > /dev/null
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan ${{ secrets.PROD_SERVER }} >> ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
export DOCKER_HOST="ssh://gitlab@${{ secrets.PROD_SERVER }}"
export MONGODB_PASSWORD="${{ secrets.PROD_MONGO_PASSWORD }}"
export BITCOIN_NODE_ADDRESS="${{ secrets.PROD_BITCOIN_NODE }}"
export BITCOIN_USERNAME="${{ secrets.PROD_BITCOIN_USERNAME }}"
export BITCOIN_PASSWORD="${{ secrets.PROD_BITCOIN_PASSWORD }}"
export OPEN_API_URL="${{ secrets.OPEN_API_URL_PROD }}"
export ETHEREUM_NODE_ADDRESS="${{ secrets.PROD_ETHEREUM_NODE_ADDRESS }}"
export ETHEREUM_ROPSTEN_NODE_ADDRESS="${{ secrets.PROD_ETHEREUM_ROPSTEN_NODE_ADDRESS }}"
export DOCKER_IMAGE_TAG="openplatform/open-state:${{ env.IMAGE_TAG }}"
docker login -u ${{ secrets.DOCKERHUB_USER_NAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
ssh -i /dev/null gitlab@${{ secrets.PROD_SERVER }} "
docker stop open-state && \
IMG=\$(docker ps -a --filter='name=^/open-state$' --format='{{.Image}}') && \
docker rm -f open-state && \
docker rmi \$IMG; \
exit 0
"
docker-compose -f docker-compose.yml up -d