diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..30d4d77 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +VITE_API_URL=http://localhost:8000/ +VITE_GOERLI_API_URL={GOERLI_API_URL_ALCHEMY} +VITE_MUMBAI_API_URL={MUMBAI_API_URL_ALCHEMY} \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d1c0b77..ac38b77 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -11,10 +11,15 @@ jobs: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID_STAGING }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_STAGING }} + ENV_VARIABLE: ${{ secrets.ENV_STAGING }} + steps: - name: 🏗 Setup repo uses: actions/checkout@v3 + - name: 🏗 Config .env + run: echo "$ENV_VARIABLE" > .env + - name: 🏗 Install Vercel CLI run: npm install --global vercel@latest @@ -33,10 +38,15 @@ jobs: env: VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + ENV_VARIABLE: ${{ secrets.ENV_PROD }} + steps: - name: 🏗 Setup repo uses: actions/checkout@v3 + - name: 🏗 Config .env + run: echo "$ENV_VARIABLE" > .env + - name: 🏗 Install Vercel CLI run: npm install --global vercel@latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c7adafd..01b910c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,10 @@ name: CI script -on: push +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] jobs: lint: @@ -13,29 +17,48 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16.x - cache: 'npm' + cache: 'yarn' - name: 🏗 Install dependencies - run: npm ci + run: yarn - name: 📦 Lint with eslint - run: npm run lint + run: yarn lint build: runs-on: ubuntu-latest + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID_STAGING }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_STAGING }} steps: - name: 🏗 Setup repo uses: actions/checkout@v3 - - name: 📦 Build docker image - run: | - docker build -t p2pix:$GITHUB_SHA . - docker save -o image_$GITHUB_SHA p2pix:$GITHUB_SHA + - name: 🏗 Install Vercel CLI + run: npm install --global vercel@latest - - name: 📦 Put docker image in cache - uses: actions/cache@v3 + - name: 🏗 Pull staging app from vercel environment + run: vercel pull --yes --token=${{ secrets.VERCEL_AUTH_TOKEN }} + + - name: 📦 Build staging app artifacts + run: vercel build --token=${{ secrets.VERCEL_AUTH_TOKEN }} + + test-coverage: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 with: - key: p2pix - path: image_${{ github.sha }} + fetch-depth: 0 - # test job \ No newline at end of file + - name: 🏗 Install dependencies + run: yarn + + - name: 📦 Test and coverage + run: yarn coverage + + - name: 📦 SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index dbad7b9..941a1f4 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ coverage *.sln *.sw? .vercel + +.env \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 02ab85e..590165e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,9 +2,9 @@ FROM node:lts-alpine WORKDIR /app -COPY package*.json ./ -RUN npm install +COPY package.json yarn.lock ./ +RUN yarn COPY ./ ./ EXPOSE 3000 -CMD ["npm", "run", "start"] \ No newline at end of file +CMD ["yarn", "start"] \ No newline at end of file diff --git a/README.md b/README.md index 909dd1d..ee195f9 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,47 @@ -# P2Pix-Front-End +
+
+
Tokens recebidos
+{{ props.tokenAmount }} BRZ
+
+ Não encontrou os tokens? Clique no botão abaixo para
+ cadastrar o BRZ em sua carteira.
+
+ ~ R$ {{ tokenValue.toFixed(2) }} +
++ ~ R$ {{ tokenValue.toFixed(2) }} +
+Tokens ofertados
+{{ props.offer }} BRZ
+Chave Pix
++ {{ props.pixKey }} +
++ Atenção! Os tokens ofertados ficam registrados no smart + contract e serão transferidos automaticamente para o comprador assim + que o Pix for detectado e confirmado. +
+README.md
.
-