hop-node: lint #910
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy | |
on: | |
push: | |
branches: | |
- production | |
- preprod | |
- mainnet | |
- develop | |
workflow_dispatch: | |
jobs: | |
set_environment: | |
name: Set Environment | |
if: contains(github.ref, 'production') || contains(github.ref, 'preprod') || contains(github.ref, 'mainnet') | |
outputs: | |
env_name: ${{ steps.setenv.outputs.env_name }} | |
dnslink_subdomain: ${{ steps.setdnslink.outputs.dnslink_subdomain }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set "environment" var | |
id: setenv | |
run: | | |
if [[ "${GITHUB_REF#refs/heads/}" == "production" || "${GITHUB_REF#refs/heads/}" == "preprod" ]] | |
then | |
echo "env_name=production" >> $GITHUB_OUTPUT | |
else | |
echo "env_name=mainnet" >> $GITHUB_OUTPUT | |
fi | |
- name: Set dnslink var | |
id: setdnslink | |
run: | | |
if [[ "${GITHUB_REF#refs/heads/}" == "production" ]] | |
then | |
echo "dnslink_subdomain=_dnslink.app" >> $GITHUB_OUTPUT | |
else | |
echo "dnslink_subdomain=_dnslink.${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
fi | |
call-workflow1: | |
name: Publish NPM Core Package If Necessary | |
uses: ./.github/workflows/npm_publish_core.yml | |
with: | |
environment: production | |
secrets: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
call-workflow2: | |
needs: call-workflow1 | |
name: Publish NPM SDK Package If Necessary | |
uses: ./.github/workflows/npm_publish_sdk.yml | |
with: | |
environment: production | |
secrets: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
bump_version: | |
name: Bump Github Release Version | |
if: contains(github.ref, 'production') | |
runs-on: ubuntu-latest | |
outputs: | |
new_tag: ${{ steps.github_tag_action.outputs.new_tag }} | |
changelog: ${{ steps.github_tag_action.outputs.changelog }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Bump version and push tag | |
id: github_tag_action | |
uses: mathieudutour/github-tag-action@331898d5052eedac9b15fec867b5ba66ebf9b692 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
release_branches: production | |
default_bump: patch | |
build: | |
if: contains(github.ref, 'production') || contains(github.ref, 'preprod') || contains(github.ref, 'mainnet') | |
name: Build and Deploy | |
runs-on: ubuntu-latest | |
needs: [set_environment, call-workflow2] | |
outputs: | |
hash: ${{ steps.upload.outputs.hash }} | |
environment: | |
name: ${{ needs.set_environment.outputs.env_name }} | |
env: | |
ENV_NAME: ${{ needs.set_environment.outputs.env_name }} | |
RECORD_NAME: ${{ needs.set_environment.outputs.dnslink_subdomain }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
defaults: | |
run: | |
working-directory: ./packages/frontend | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Log set env vars | |
run: | | |
echo "ENV_NAME=${ENV_NAME}" | |
echo "RECORD_NAME=${RECORD_NAME}" | |
- name: Set up node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 14.17.6 | |
registry-url: https://registry.npmjs.org | |
- name: Update npm | |
run: npm install -g npm@latest | |
- name: Install node dependencies | |
run: npm install | |
- name: Build the frontend app | |
env: | |
PUBLIC_URL: ${{ secrets.PUBLIC_URL }} | |
REACT_APP_NETWORK: ${{ secrets.REACT_APP_NETWORK }} | |
REACT_APP_IPFS_BUILD: ${{ secrets.REACT_APP_IPFS_BUILD }} | |
REACT_APP_BNC_DAPP_ID: ${{ secrets.REACT_APP_BNC_DAPP_ID }} | |
REACT_APP_ENABLED_CHAINS: ${{ secrets.REACT_APP_ENABLED_CHAINS }} | |
REACT_APP_ENABLED_TOKENS: ${{ secrets.REACT_APP_ENABLED_TOKENS }} | |
REACT_APP_FORTMATIC_KEY: ${{ secrets.REACT_APP_FORTMATIC_KEY }} | |
REACT_APP_DISABLED_ROUTES: ${{ secrets.REACT_APP_DISABLED_ROUTES }} | |
REACT_APP_WARNING_ROUTES: ${{ secrets.REACT_APP_WARNING_ROUTES }} | |
REACT_APP_DISABLE_NATIVE_ASSET_TRANSFERS: ${{ secrets.REACT_APP_DISABLE_NATIVE_ASSET_TRANSFERS }} | |
REACT_APP_DISABLED_ROUTES_NO_LIQUIDITY_WARNING_MESSAGE: ${{ secrets.REACT_APP_DISABLED_ROUTES_NO_LIQUIDITY_WARNING_MESSAGE }} | |
REACT_APP_SHOW_BANNER_MESSAGE: ${{ secrets.REACT_APP_SHOW_BANNER_MESSAGE }} | |
REACT_APP_BLOCKLIST_ENABLED: ${{ secrets.REACT_APP_BLOCKLIST_ENABLED }} | |
run: npm run build | |
- name: Write commit file | |
uses: "DamianReeves/write-file-action@a432935930b2e351ec2d2792fc220717b656ec1c" | |
with: | |
path: packages/frontend/build/cachebust | |
write-mode: overwrite | |
contents: ${{ github.sha }} | |
- name: Pin to IPFS on Pinata | |
id: upload | |
uses: anantaramdas/ipfs-pinata-deploy-action@9f9c3b42b5d360352c4b768d98aff1309d62faa0 | |
with: | |
pin-name: Hop ${{ github.sha }} | |
path: './packages/frontend/build' | |
verbose: true | |
pinata-api-key: ${{ secrets.IPFS_DEPLOY_PINATA__API_KEY }} | |
pinata-secret-api-key: ${{ secrets.IPFS_DEPLOY_PINATA__SECRET_API_KEY }} | |
- name: Update CloudFlare DNS with new IPFS hash | |
env: | |
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} | |
RECORD_DOMAIN: 'hop.exchange' | |
RECORD_NAME: ${{ needs.set_environment.outputs.dnslink_subdomain }} | |
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
uses: textileio/cloudflare-update-dnslink@30414a408191218c8259e932ebdf4cbb7c652fe8 | |
with: | |
cid: ${{ steps.upload.outputs.hash }} | |
- name: Convert CIDv0 to CIDv1 | |
id: convert_cidv0 | |
uses: uniswap/[email protected] | |
with: | |
cidv0: ${{ steps.upload.outputs.hash }} | |
- name: Set short sha | |
id: vars | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Create GitHub Release | |
id: create_release | |
if: contains(github.ref, 'production') | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ needs.bump_version.outputs.new_tag || steps.vars.outputs.sha_short }} | |
release_name: Release ${{ needs.bump_version.outputs.new_tag || steps.vars.outputs.sha_short }} | |
body: | | |
IPFS hash of the deployment: | |
- CIDv0: `${{ steps.upload.outputs.hash }}` | |
- CIDv1: `${{ steps.convert_cidv0.outputs.cidv1 }}` | |
The latest release is always accessible via our alias to the Cloudflare IPFS gateway at [app.hop.exchange](https://app.hop.exchange). | |
You can also access the Hop Interface directly from an IPFS gateway. | |
**Note**: The Hop interface uses [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to remember your settings, such as slippage tolerance. | |
**You should always use an IPFS gateway that enforces origin separation**, or our alias to the latest release at [app.hop.exchange](https://app.hop.exchange). | |
Your Hop settings are never remembered across different URLs. | |
IPFS gateways: | |
- https://${{ steps.convert_cidv0.outputs.cidv1 }}.ipfs.cf-ipfs.com/ | |
- https://${{ steps.convert_cidv0.outputs.cidv1 }}.ipfs.dweb.link/ | |
- https://hop.mypinata.cloud/ipfs/${{ steps.upload.outputs.hash }}/ | |
- https://gateway.pinata.cloud/ipfs/${{ steps.upload.outputs.hash }}/ | |
- https://cloudflare-ipfs.com/ipfs/${{ steps.upload.outputs.hash }}/ | |
- https://gateway.ipfs.io/ipfs/${{ steps.upload.outputs.hash }}/ | |
- https://crustwebsites.net/ipfs/${{ steps.upload.outputs.hash }}/ | |
- [ipfs://${{ steps.upload.outputs.hash }}/](ipfs://${{ steps.upload.outputs.hash }}/) | |
- https://hop.eth.limo/ | |
- https://hop.eth.link/ | |
${{ needs.bump_version.outputs.changelog }} |