Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into deploy/dot-seller
Browse files Browse the repository at this point in the history
  • Loading branch information
samchuk-vlad committed Sep 13, 2023
2 parents ced4adc + e8854f4 commit 8537a6c
Show file tree
Hide file tree
Showing 175 changed files with 7,440 additions and 3,615 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ node_modules/
.storybook/
.vscode/
**/stories/
docker/
deployment/
.github/
51 changes: 51 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
name: 🐛 Bug Report
about: Template for reporting bugs
title: '<title>'
labels: bug
assignees: ''
---

<!--
Note: Please search to see if an issue already exists for the bug you encountered.
-->

### Current Behavior:

<!-- A concise description of what you're experiencing. -->

### Expected Behavior:

<!-- A concise description of what you expected to happen. -->

### Steps To Reproduce:

<!--
Example: steps to reproduce the behavior:
1. In this environment...
1. With this config...
1. Run '...'
1. See error...
-->

## Environment

<!-- What is the environment that the bug happens?
Example:
- OS: Ubuntu 20.04
- Node: 13.14.0
- npm: 7.6.3
-->

## ✔️ Possible solutions

<!-- (This section is optional.)
Any hint on how to solve the issue?
What parts of the code will be affected?
-->

### Anything else:

<!--
Links? References? Anything that will give us more context about the issue that you are encountering!
-->
34 changes: 34 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: ✨ Feature request
about: Template for requesting new features
title: '<title>'
labels: enhancement
assignees: ''
---

## 📚 Context

<!--
What is the problem that you are trying to solve?
Why is this problem relevant?
-->

## ✔️ Solution

<!--
(This section and the ones below are optional.)
What are the possible solutions?
If there are multiple, what are the benefits and drawbacks of each one?
-->

## 📈 Subtasks

<!--
- [ ] If there is a solution, what are the subtasks for completing this issue?
-->

## 🎯 Definition of Done

<!--
- [ ] If there is a solution, what are the final deliverables?
-->
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
reviewers:
- 'oap75'
- 'olehmell'
schedule:
interval: 'weekly'
commit-message:
prefix: 'dependabot'
pull-request-branch-name:
separator: '/'
33 changes: 33 additions & 0 deletions .github/workflows/base-docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build and deploy base image for web app
on:
push:
branches:
- '**'
paths:
- 'docker/**'

jobs:
base_front_build:
name: build & Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master

- name: Login to DockerHub
uses: docker/login-action@master
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build base image
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: docker/BaseDockerfile
push: true
tags: |
dappforce/subsocial-base-polkaverse
25 changes: 15 additions & 10 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ on:
branches:
- staging
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
front_build:
name: build & Push Docker image to Docker Hub
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
Expand Down Expand Up @@ -41,7 +44,7 @@ jobs:
- if: ${{ github.ref == 'refs/heads/staging' }}
name: Build staging image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
Expand All @@ -59,7 +62,7 @@ jobs:

- if: ${{ github.ref == 'refs/heads/main' }}
name: Build production image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
Expand All @@ -68,7 +71,10 @@ jobs:
build-args: |
GH_GA_ID=UA-204866512-2
GH_APP_KIND=polkaverse
GH_CONNECTION_KIND=staging
GH_HCAPTCHA_SITE_KEY=${{ secrets.PROD_HCAPTCHA_SITE_KEY }}
GH_AMP_ID=2eeca0e8a0163c89e3f023c971e426a6
GH_OFFCHAIN_SIGNER_URL=https://signer.subsocial.network
GH_CONNECTION_KIND=main
tags: |
${{ env.image }}
Expand All @@ -88,7 +94,7 @@ jobs:
if: ${{ github.ref == 'refs/heads/staging' }}
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract branch name
shell: bash
Expand Down Expand Up @@ -118,7 +124,7 @@ jobs:
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract branch name
shell: bash
Expand All @@ -136,9 +142,9 @@ jobs:
- name: Update deploy file
run: TAG=${{ env.name }}-$(echo $GITHUB_SHA | head -c7) && sed -i 's|<IMAGE>|dappforce/subsocial-web-app:'${TAG}'|' $GITHUB_WORKSPACE/deployment/base/deployment.yaml

- name: Remove HPA
- name: Remove HPA
run: kubectl delete hpa -n sub-back web-app

- name: Deploy to DigitalOcean Kubernetes
run: kubectl apply -k $GITHUB_WORKSPACE/deployment/overlays/production/

Expand All @@ -151,15 +157,14 @@ jobs:
- name: Recreate HPA
run: kubectl create -f $GITHUB_WORKSPACE/deployment/hpa/hpa.yaml


front-bk-prod-deploy:
name: bk-prod-deploy
needs: front_build
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract branch name
shell: bash
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/feature-based-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4

- uses: mdecoleman/pr-branch-name@1.2.0
- uses: mdecoleman/pr-branch-name@2.0.0
id: vars
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Get CF A record ID
continue-on-error: true
shell: bash
run: echo "record=$(echo $(curl -X GET "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/dns_records?type=A&name=${{ env.name }}.subsocial.network&content=188.166.202.107&proxied=true&page=1&per_page=100&order=type&direction=desc&match=all" -H "X-Auth-Email:${{ secrets.CF_MAIL }}" -H "Authorization:Bearer ${{ secrets.CF_TOKEN }}" -H "Content-Type:application/json" | jq . | jq -c '.result[]' | jq -r .id) )" >> $GITHUB_ENV
run: echo "record=$(echo $(curl -X GET "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/dns_records?type=A&name=${{ env.name }}.subsocial.network&content=174.138.105.155&proxied=true&page=1&per_page=100&order=type&direction=desc&match=all" -H "X-Auth-Email:${{ secrets.CF_MAIL }}" -H "Authorization:Bearer ${{ secrets.CF_TOKEN }}" -H "Content-Type:application/json" | jq . | jq -c '.result[]' | jq -r .id) )" >> $GITHUB_ENV
id: cf

- name: delete CF A record
Expand Down
29 changes: 21 additions & 8 deletions .github/workflows/feature-based.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ on:
push:
branches:
- deploy/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
front_build:
name: build & Push Docker image to Docker Hub
runs-on: ubuntu-latest
# runs-on: public-runners
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Extract branch name
shell: bash
run: echo "name=$(echo ${GITHUB_REF#refs/heads/} | sed 's/^deploy\///')" >> $GITHUB_ENV
Expand All @@ -21,9 +25,17 @@ jobs:
run: |
echo "image=dappforce/subsocial-web-app:${{ env.name }}-$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_ENV
- name: Set up Docker context for buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
with:
endpoint: builders
version: latest

- name: Login to DockerHub
uses: docker/login-action@master
Expand All @@ -40,18 +52,19 @@ jobs:
${{ runner.os }}-single-buildx
- name: Build docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: docker/Dockerfile
push: true
build-args: |
GH_GA_ID=fake
GH_APP_KIND=staging
GH_CONNECTION_KIND=staging
GH_SELLER_CLIENT_ID=${{ secrets.STAGING_GH_SELLER_CLIENT_ID }}
GH_SELLER_TOKEN_SIGNER=${{ secrets.STAGING_GH_SELLER_TOKEN_SIGNER }}
GH_APP_KIND=polkaverse
GH_HCAPTCHA_SITE_KEY=3beeddac-2dce-41cc-8e18-338118426c38
GH_AMP_ID=71bf5a46800fedba5e9a01243b988164
GH_OFFCHAIN_SIGNER_URL=https://signer.subsocial.network
GH_CONNECTION_KIND=dev
tags: |
${{ env.image }}
cache-from: type=local,src=/tmp/.buildx-cache
Expand All @@ -68,7 +81,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Extract branch name
shell: bash
Expand Down Expand Up @@ -99,4 +112,4 @@ jobs:
run: NAME=${{ env.name }} && kubectl -n sub-back rollout status deployment/web-app-${NAME}

- name: CF deploy
run: curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/dns_records" -H "X-Auth-Email:${{ secrets.CF_MAIL }}" -H "Authorization:Bearer ${{ secrets.CF_TOKEN }}" -H "Content-Type:application/json" --data '{"type":"A","name":"${{ env.name }}.subsocial.network","content":"188.166.202.107","ttl":3600,"priority":10,"proxied":true}'
run: curl -X POST "https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/dns_records" -H "X-Auth-Email:${{ secrets.CF_MAIL }}" -H "Authorization:Bearer ${{ secrets.CF_TOKEN }}" -H "Content-Type:application/json" --data '{"type":"A","name":"${{ env.name }}.subsocial.network","content":"174.138.105.155","ttl":3600,"priority":10,"proxied":true}'
11 changes: 11 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# NOTICE

polkaverse by DAPPFORCE PTE. LTD.

Copyright (C) 2022-2023 DAPPFORCE PTE. LTD.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License at https://github.com/dappforce/polkaverse/blob/main/LICENSE for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ yarn
Dev mode supports hot reloads – this is very helpful when developing UI because you can see changes in your browser without restarting the app. But it takes some time (in seconds) to compile the updated parts of the app, after you made changes to the source code.

```sh
yarn dev
yar dev
```

### Option B: Run in a PROD mode
Expand Down
25 changes: 13 additions & 12 deletions ci.env
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
LOG_LEVEL=info
NEXT_PUBLIC_APP_KIND=subsocial
NEXT_PUBLIC_CONNECTION_KIND='$GH_CONNECTION_KIND'
NEXT_PUBLIC_SUBSTRATE_URL='$GH_SUBSTRATE_URL'
NEXT_PUBLIC_SUBSTRATE_RPC_URL='$GH_SUBSTRATE_RPC_URL'
NEXT_PUBLIC_OFFCHAIN_URL='$GH_OFFCHAIN_URL'
NEXT_PUBLIC_OFFCHAIN_WS='$GH_OFFCHAIN_WS'
NEXT_PUBLIC_IPFS_NODE_URL='$GH_IPFS_NODE_URL'
NEXT_PUBLIC_GA_ID='$GH_GA_ID'
NEXT_PUBLIC_APP_KIND='$GH_APP_KIND'
NEXT_PUBLIC_APP_BASE_URL='$GH_APP_BASE_URL'
SELLER_CLIENT_ID='$GH_SELLER_CLIENT_ID'
SELLER_CLIENT_TOKEN_SIGNER='$GH_SELLER_TOKEN_SIGNER'
APP_KIND=subsocial
CONNECTION_KIND='$GH_CONNECTION_KIND'
SUBSTRATE_URL='$GH_SUBSTRATE_URL'
SUBSTRATE_RPC_URL='$GH_SUBSTRATE_RPC_URL'
OFFCHAIN_URL='$GH_OFFCHAIN_URL'
OFFCHAIN_WS='$GH_OFFCHAIN_WS'
IPFS_NODE_URL='$GH_IPFS_NODE_URL'
GA_ID='$GH_GA_ID'
APP_KIND='$GH_APP_KIND'
APP_BASE_URL='$GH_APP_BASE_URL'
HCAPTCHA_SITE_KEY='$GH_HCAPTCHA_SITE_KEY'
OFFCHAIN_SIGNER_URL='$GH_OFFCHAIN_SIGNER_URL'
AMP_ID='$GH_AMP_ID'
4 changes: 2 additions & 2 deletions deployment/hpa/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: autoscaling/v2beta2
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
creationTimestamp: null
Expand All @@ -18,7 +18,7 @@ spec:
name: memory
target:
type: Utilization
averageUtilization: 90
averageUtilization: 90
- type: Resource
resource:
name: cpu
Expand Down
Loading

0 comments on commit 8537a6c

Please sign in to comment.