Skip to content

Commit

Permalink
Merge pull request #36 from bosonprotocol/staging-deployment
Browse files Browse the repository at this point in the history
ci: staging deployment
  • Loading branch information
levalleux-ludo authored Aug 8, 2023
2 parents 52258bc + 9d2d0ee commit 17a92f1
Show file tree
Hide file tree
Showing 6 changed files with 8,057 additions and 248 deletions.
30 changes: 30 additions & 0 deletions .fleek_production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"site": {
"id": "fd6f14bd-0da9-4c7b-b1f2-56480be80ae8",
"team": "3fb24a6e-7168-438e-848a-8b706e8bb76a",
"platform": "ipfs",
"source": "ipfs",
"name": "widgets-production"
},
"build": {
"baseDir": "",
"publicDir": "build",
"command": "npm run build",
"environment": {
"REACT_APP_DEFAULT_TOKENS_LIST_TESTING": "[{\"symbol\":\"MATIC\",\"name\":\"MATIC\",\"address\":\"0x0000000000000000000000000000000000000000\",\"decimals\":\"18\"},{\"symbol\":\"WETH\",\"name\":\"Wrapped Ether\",\"address\":\"0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa\",\"decimals\":\"18\"},{\"symbol\":\"BOSON\",\"name\":\"Boson Token (PoS)\",\"address\":\"0x1f5431E8679630790E8EbA3a9b41d1BB4d41aeD0\",\"decimals\":\"18\"},{\"symbol\":\"USDC\",\"name\":\"Mumbai USD Coin\",\"address\":\"0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747\",\"decimals\":\"6\"},{\"symbol\":\"DAI\",\"name\":\"DAI\",\"address\":\"0x001b3b4d0f3714ca98ba10f6042daebf0b1b7b6f\",\"decimals\":\"18\"},{\"symbol\":\"USDT\",\"name\":\"Tether USD\",\"address\":\"0xA02f6adc7926efeBBd59Fd43A84f4E0c0c91e832\",\"decimals\":\"6\"}]",
"REACT_APP_DEFAULT_TOKENS_LIST_STAGING": "[{\"symbol\":\"MATIC\",\"name\":\"MATIC\",\"address\":\"0x0000000000000000000000000000000000000000\",\"decimals\":\"18\"},{\"symbol\":\"WETH\",\"name\":\"Wrapped Ether\",\"address\":\"0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa\",\"decimals\":\"18\"},{\"symbol\":\"BOSON\",\"name\":\"Boson Token (PoS)\",\"address\":\"0x1f5431E8679630790E8EbA3a9b41d1BB4d41aeD0\",\"decimals\":\"18\"},{\"symbol\":\"USDC\",\"name\":\"Mumbai USD Coin\",\"address\":\"0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747\",\"decimals\":\"6\"},{\"symbol\":\"DAI\",\"name\":\"DAI\",\"address\":\"0x001b3b4d0f3714ca98ba10f6042daebf0b1b7b6f\",\"decimals\":\"18\"},{\"symbol\":\"USDT\",\"name\":\"Tether USD\",\"address\":\"0xA02f6adc7926efeBBd59Fd43A84f4E0c0c91e832\",\"decimals\":\"6\"}]",
"REACT_APP_DEFAULT_TOKENS_LIST_PRODUCTION": "[{\"symbol\":\"MATIC\",\"name\":\"MATIC\",\"address\":\"0x0000000000000000000000000000000000000000\",\"decimals\":\"18\"},{\"symbol\":\"WETH\",\"name\":\"Wrapped Ether\",\"address\":\"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619\",\"decimals\":\"18\"},{\"symbol\":\"BOSON\",\"name\":\"Boson Token (PoS)\",\"address\":\"0x9B3B0703D392321AD24338Ff1f846650437A43C9\",\"decimals\":\"18\"},{\"symbol\":\"USDC\",\"name\":\"USD Coin (PoS)\",\"address\":\"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\"decimals\":\"6\"},{\"symbol\":\"DAI\",\"name\":\"(PoS) Dai Stablecoin\",\"address\":\"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063\",\"decimals\":\"18\"},{\"symbol\":\"USDT\",\"name\":\"(PoS) Tether USD\",\"address\":\"0xc2132D05D31c914a87C6611C10748AEb04B58e8F\",\"decimals\":\"6\"}]",
"REACT_APP_DEFAULT_DISPUTE_RESOLVER_ID_TESTING": "13",
"REACT_APP_DEFAULT_DISPUTE_RESOLVER_ID_STAGING": "2",
"REACT_APP_DEFAULT_DISPUTE_RESOLVER_ID_PRODUCTION": "1",
"REACT_APP_DEFAULT_DISPUTE_PERIOD_DAYS": "30",
"REACT_APP_DEFAULT_RESOLUTION_PERIOD_DAYS": "15",
"REACT_APP_CONTACT_SELLER_FOR_EXCHANGE_TESTING": "https://interface-test.on.fleek.co/#/chat/{id}",
"REACT_APP_CONTACT_SELLER_FOR_EXCHANGE_STAGING": "https://interface-staging.on.fleek.co/#/chat/{id}",
"REACT_APP_CONTACT_SELLER_FOR_EXCHANGE_PRODUCTION": "https://bosonapp.io/#/chat/{id}",
"REACT_APP_BUYER_SELLER_AGREEMENT_TEMPLATE": "ipfs://QmXfDShmggHm7BzMbkzv2rRowwPyJ55mypGp32qKSPGto4",
"REACT_APP_RNFT_LICENSE_TEMPLATE": "ipfs://QmUxAXqM6smDYj7TvS9oDe5kRoAVmkqcyWCKEeNsD6JA97",
"REACT_APP_FAIR_EXCHANGE_POLICY_RULES": "ipfs://QmV3Wy2wmrFdEXzhyhvvaW25Q8w2wTd2UypFVyhwsdBE8T"
}
}
}
30 changes: 30 additions & 0 deletions .fleek_staging.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"site": {
"id": "345d675a-ce7a-4116-89bd-6a02ea18c8c6",
"team": "3fb24a6e-7168-438e-848a-8b706e8bb76a",
"platform": "ipfs",
"source": "ipfs",
"name": "widgets-staging"
},
"build": {
"baseDir": "",
"publicDir": "build",
"command": "npm run build",
"environment": {
"REACT_APP_DEFAULT_TOKENS_LIST_TESTING": "[{\"symbol\":\"MATIC\",\"name\":\"MATIC\",\"address\":\"0x0000000000000000000000000000000000000000\",\"decimals\":\"18\"},{\"symbol\":\"WETH\",\"name\":\"Wrapped Ether\",\"address\":\"0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa\",\"decimals\":\"18\"},{\"symbol\":\"BOSON\",\"name\":\"Boson Token (PoS)\",\"address\":\"0x1f5431E8679630790E8EbA3a9b41d1BB4d41aeD0\",\"decimals\":\"18\"},{\"symbol\":\"USDC\",\"name\":\"Mumbai USD Coin\",\"address\":\"0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747\",\"decimals\":\"6\"},{\"symbol\":\"DAI\",\"name\":\"DAI\",\"address\":\"0x001b3b4d0f3714ca98ba10f6042daebf0b1b7b6f\",\"decimals\":\"18\"},{\"symbol\":\"USDT\",\"name\":\"Tether USD\",\"address\":\"0xA02f6adc7926efeBBd59Fd43A84f4E0c0c91e832\",\"decimals\":\"6\"}]",
"REACT_APP_DEFAULT_TOKENS_LIST_STAGING": "[{\"symbol\":\"MATIC\",\"name\":\"MATIC\",\"address\":\"0x0000000000000000000000000000000000000000\",\"decimals\":\"18\"},{\"symbol\":\"WETH\",\"name\":\"Wrapped Ether\",\"address\":\"0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa\",\"decimals\":\"18\"},{\"symbol\":\"BOSON\",\"name\":\"Boson Token (PoS)\",\"address\":\"0x1f5431E8679630790E8EbA3a9b41d1BB4d41aeD0\",\"decimals\":\"18\"},{\"symbol\":\"USDC\",\"name\":\"Mumbai USD Coin\",\"address\":\"0xe6b8a5CF854791412c1f6EFC7CAf629f5Df1c747\",\"decimals\":\"6\"},{\"symbol\":\"DAI\",\"name\":\"DAI\",\"address\":\"0x001b3b4d0f3714ca98ba10f6042daebf0b1b7b6f\",\"decimals\":\"18\"},{\"symbol\":\"USDT\",\"name\":\"Tether USD\",\"address\":\"0xA02f6adc7926efeBBd59Fd43A84f4E0c0c91e832\",\"decimals\":\"6\"}]",
"REACT_APP_DEFAULT_TOKENS_LIST_PRODUCTION": "[{\"symbol\":\"MATIC\",\"name\":\"MATIC\",\"address\":\"0x0000000000000000000000000000000000000000\",\"decimals\":\"18\"},{\"symbol\":\"WETH\",\"name\":\"Wrapped Ether\",\"address\":\"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619\",\"decimals\":\"18\"},{\"symbol\":\"BOSON\",\"name\":\"Boson Token (PoS)\",\"address\":\"0x9B3B0703D392321AD24338Ff1f846650437A43C9\",\"decimals\":\"18\"},{\"symbol\":\"USDC\",\"name\":\"USD Coin (PoS)\",\"address\":\"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174\",\"decimals\":\"6\"},{\"symbol\":\"DAI\",\"name\":\"(PoS) Dai Stablecoin\",\"address\":\"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063\",\"decimals\":\"18\"},{\"symbol\":\"USDT\",\"name\":\"(PoS) Tether USD\",\"address\":\"0xc2132D05D31c914a87C6611C10748AEb04B58e8F\",\"decimals\":\"6\"}]",
"REACT_APP_DEFAULT_DISPUTE_RESOLVER_ID_TESTING": "13",
"REACT_APP_DEFAULT_DISPUTE_RESOLVER_ID_STAGING": "2",
"REACT_APP_DEFAULT_DISPUTE_RESOLVER_ID_PRODUCTION": "1",
"REACT_APP_DEFAULT_DISPUTE_PERIOD_DAYS": "30",
"REACT_APP_DEFAULT_RESOLUTION_PERIOD_DAYS": "15",
"REACT_APP_CONTACT_SELLER_FOR_EXCHANGE_TESTING": "https://interface-test.on.fleek.co/#/chat/{id}",
"REACT_APP_CONTACT_SELLER_FOR_EXCHANGE_STAGING": "https://interface-staging.on.fleek.co/#/chat/{id}",
"REACT_APP_CONTACT_SELLER_FOR_EXCHANGE_PRODUCTION": "https://bosonapp.io/#/chat/{id}",
"REACT_APP_BUYER_SELLER_AGREEMENT_TEMPLATE": "ipfs://QmXfDShmggHm7BzMbkzv2rRowwPyJ55mypGp32qKSPGto4",
"REACT_APP_RNFT_LICENSE_TEMPLATE": "ipfs://QmUxAXqM6smDYj7TvS9oDe5kRoAVmkqcyWCKEeNsD6JA97",
"REACT_APP_FAIR_EXCHANGE_POLICY_RULES": "ipfs://QmV3Wy2wmrFdEXzhyhvvaW25Q8w2wTd2UypFVyhwsdBE8T"
}
}
}
123 changes: 123 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Call reusable workflow - Widgets

on:
release:
types: [created]
pull_request:
branches:
- main
workflow_dispatch:

jobs:
prejob:
name: Get Latest Tag
runs-on: ubuntu-latest
outputs:
releaseTag: ${{ steps.tag.outputs.tag }}
releaseName: ${{ steps.name.outputs.name }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: "WyriHaximus/github-action-get-previous-tag@v1"
id: tag
- run: echo "name=$(git describe --tags)" >> $GITHUB_OUTPUT
id: name

call-reusable-workflow-staging:
uses: ./.github/workflows/ci_reusable.yaml
if: github.event_name == 'release' && github.event.action == 'created'
needs: prejob
with:
ENV_NAME: "staging"
REACT_APP_ENV_NAME: "staging"
DEPLOY_TO_FLEEK: true
REACT_APP_RELEASE_TAG: ${{ needs.prejob.outputs.releaseTag }}
REACT_APP_RELEASE_NAME: ${{ needs.prejob.outputs.releaseName }}
secrets:
FLEEK_API_KEY: ${{ secrets.FLEEK_API_KEY }}
REACT_APP_INFURA_IPFS_PROJECT_ID: ${{ secrets.REACT_APP_INFURA_IPFS_PROJECT_ID }}
REACT_APP_INFURA_IPFS_PROJECT_SECRET: ${{ secrets.REACT_APP_INFURA_IPFS_PROJECT_SECRET }}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID_STAGING }}
REACT_APP_META_TX_API_KEY: ${{ secrets.REACT_APP_META_TX_API_KEY_STAGING }}
REACT_APP_META_TX_API_IDS: ${{ secrets.REACT_APP_META_TX_API_IDS_STAGING }}

call-reusable-workflow-production:
uses: ./.github/workflows/ci_reusable.yaml
if: github.event_name == 'workflow_dispatch'
needs: prejob
with:
ENV_NAME: "production"
REACT_APP_ENV_NAME: "production"
DEPLOY_TO_FLEEK: true
REACT_APP_RELEASE_TAG: ${{ needs.prejob.outputs.releaseTag }}
REACT_APP_RELEASE_NAME: ${{ needs.prejob.outputs.releaseName }}
secrets:
FLEEK_API_KEY: ${{ secrets.FLEEK_API_KEY }}
REACT_APP_INFURA_IPFS_PROJECT_ID: ${{ secrets.REACT_APP_INFURA_IPFS_PROJECT_ID }}
REACT_APP_INFURA_IPFS_PROJECT_SECRET: ${{ secrets.REACT_APP_INFURA_IPFS_PROJECT_SECRET }}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID_PRODUCTION }}
REACT_APP_META_TX_API_KEY: ${{ secrets.REACT_APP_META_TX_API_KEY_PRODUCTION }}
REACT_APP_META_TX_API_IDS: ${{ secrets.REACT_APP_META_TX_API_IDS_PRODUCTION }}

job-summary:
name: Create Job Summary
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }}
needs:
[
call-reusable-workflow-staging,
call-reusable-workflow-production
]
steps:
- uses: actions/checkout@v3
- name: Install JQ
uses: r26d/jq-action@master
with:
cmd: jq -n env
- name: Get job outputs
env:
OUTPUTS: ${{ toJSON(needs) }}
run: |
succeededJobOutput="$(
echo '${{ env.OUTPUTS }}' | jq '.[] | select(.result | startswith("success")) | .outputs'
)"
echo 'JOB_OUTPUT='$succeededJobOutput >> $GITHUB_ENV
- name: Get job vars
run: |
jobLint="$(
echo '${{ env.JOB_OUTPUT }}' |
jq '.JOB_LINT'
)"
echo 'JOB_LINT='$jobLint >> $GITHUB_ENV
jobBuild="$(
echo '${{ env.JOB_OUTPUT }}' |
jq '.JOB_BUILD'
)"
echo 'JOB_BUILD='$jobBuild >> $GITHUB_ENV
deployUrl="$(
echo '${{ env.JOB_OUTPUT }}' |
jq '.DEPLOY_URL'
)"
echo 'DEPLOY_URL='$deployUrl >> $GITHUB_ENV
- name: Adding Job Summary
run: |
echo "| Command | Status |" >> $GITHUB_STEP_SUMMARY
echo "| ---- | ---- |" >> $GITHUB_STEP_SUMMARY
if [ ${{ env.JOB_LINT }} == success ]; then
echo "| Lint | ✅ |" >> $GITHUB_STEP_SUMMARY
else
echo "| Lint | ❌ |" >> $GITHUB_STEP_SUMMARY
fi
if [ ${{ env.JOB_BUILD }} == success ]; then
echo "| Build | ✅ |" >> $GITHUB_STEP_SUMMARY
else
echo "| Build | ❌ |" >> $GITHUB_STEP_SUMMARY
fi
- name: Adding Job Summary Deploy Url
if: ${{ env.DEPLOY_URL }}
run: echo "| URL | ${{ env.DEPLOY_URL }} |" >> $GITHUB_STEP_SUMMARY
97 changes: 97 additions & 0 deletions .github/workflows/ci_reusable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build, Test and Deploy the Hosted Widgets - Reusable workflow

on:
workflow_call:
inputs:
ENV_NAME:
required: true
type: string
REACT_APP_ENV_NAME:
required: true
type: string
DEPLOY_TO_FLEEK:
required: true
type: boolean
REACT_APP_RELEASE_TAG:
required: false
type: string
REACT_APP_RELEASE_NAME:
required: false
type: string
secrets:
FLEEK_API_KEY:
required: false
REACT_APP_INFURA_IPFS_PROJECT_ID:
required: false
REACT_APP_INFURA_IPFS_PROJECT_SECRET:
required: false
REACT_APP_WALLET_CONNECT_PROJECT_ID:
required: true
REACT_APP_META_TX_API_KEY:
required: true
REACT_APP_META_TX_API_IDS:
required: true
outputs:
JOB_LINT:
value: ${{ jobs.build-test-deploy.outputs.jobLint }}
JOB_BUILD:
value: ${{ jobs.build-test-deploy.outputs.jobBuild }}
DEPLOY_URL:
value: ${{ jobs.build-test-deploy.outputs.deployUrl }}

jobs:
build-test-deploy:
name: Build, Test and Deploy the Hosted Widgets
runs-on: ubuntu-latest
env:
REACT_APP_ENV_NAME: ${{ inputs.REACT_APP_ENV_NAME }}
REACT_APP_RELEASE_TAG: ${{ inputs.REACT_APP_RELEASE_TAG }}
REACT_APP_RELEASE_NAME: ${{ inputs.REACT_APP_RELEASE_NAME }}
REACT_APP_INFURA_IPFS_PROJECT_ID: ${{ secrets.REACT_APP_INFURA_IPFS_PROJECT_ID }}
REACT_APP_INFURA_IPFS_PROJECT_SECRET: ${{ secrets.REACT_APP_INFURA_IPFS_PROJECT_SECRET }}
REACT_APP_WALLET_CONNECT_PROJECT_ID: ${{ secrets.REACT_APP_WALLET_CONNECT_PROJECT_ID }}
REACT_APP_META_TX_API_KEY: ${{ secrets.REACT_APP_META_TX_API_KEY }}
REACT_APP_META_TX_API_IDS: ${{ secrets.REACT_APP_META_TX_API_IDS }}
outputs:
jobLint: ${{ steps.lint.outputs.pass }}
jobBuild: ${{ steps.build.outputs.pass }}
deployUrl: ${{ steps.deploy.outputs.deployUrl }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: "17"
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-
- run: npm ci
- run: npm run prettier
- run: npm run lint
- id: lint
run: echo "::set-output name=pass::success"
- run: npm run build
- id: build
run: echo "::set-output name=pass::success"
- name: (if 'staging' env) Copy contents from .fleek_staging.json to .fleek.json
if: ${{ inputs.ENV_NAME == 'staging' }}
run: mv .fleek_staging.json .fleek.json
- name: (if 'production' env) Copy contents from .fleek_production.json to .fleek.json
if: ${{ inputs.ENV_NAME == 'production' }}
run: mv .fleek_production.json .fleek.json
- name: Deploy via fleek
if: ${{ inputs.DEPLOY_TO_FLEEK }}
id: deploy
uses: fleekhq/action-deploy@v1
with:
apiKey: ${{ secrets.FLEEK_API_KEY }}
- name: Get the output url
if: ${{ inputs.DEPLOY_TO_FLEEK }}
run: echo "Deploy url is ${{ steps.deploy.outputs.deployUrl }}"
Loading

0 comments on commit 17a92f1

Please sign in to comment.