Deploy SDK Staging #61
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 SDK Staging' | |
on: | |
workflow_dispatch: | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
deploy: | |
name: Build & Deploy SDK to staging using SST | |
environment: staging | |
runs-on: ubuntu-latest | |
env: | |
ONE_INCH_API_KEY: ${{ secrets.ONE_INCH_API_KEY }} | |
ONE_INCH_API_VERSION: ${{ secrets.ONE_INCH_API_VERSION }} | |
ONE_INCH_API_URL: ${{ secrets.ONE_INCH_API_URL }} | |
ONE_INCH_ALLOWED_SWAP_PROTOCOLS: ${{ secrets.ONE_INCH_ALLOWED_SWAP_PROTOCOLS }} | |
ONE_INCH_SWAP_CHAIN_IDS: ${{ secrets.ONE_INCH_SWAP_CHAIN_IDS }} | |
ONE_INCH_API_SPOT_URL: ${{ secrets.ONE_INCH_API_SPOT_URL }} | |
ONE_INCH_API_SPOT_VERSION: ${{ secrets.ONE_INCH_API_SPOT_VERSION }} | |
ONE_INCH_API_SPOT_KEY: ${{ secrets.ONE_INCH_API_SPOT_KEY }} | |
MAINNET_RPC_URL: ${{ secrets.MAINNET_RPC_URL }} | |
SUBGRAPH_BASE: ${{ secrets.SUBGRAPH_BASE }} | |
RPC_GATEWAY: ${{ secrets.RPC_GATEWAY }} | |
DEBANK_API_KEY: ${{ secrets.DEBANK_API_KEY }} | |
DEBANK_API_URL: ${{ secrets.STAGING_DEBANK_API_URL }} | |
FUNCTIONS_API_URL: ${{ secrets.FUNCTIONS_API_URL }} | |
POWERTOOLS_LOG_LEVEL: ${{ vars.POWERTOOLS_LOG_LEVEL }} | |
REDIS_CACHE_URL: ${{ secrets.REDIS_CACHE_URL }} | |
REDIS_CACHE_USER: ${{ secrets.REDIS_CACHE_USER }} | |
REDIS_CACHE_PASSWORD: ${{ secrets.REDIS_CACHE_PASSWORD }} | |
VPC_ID: ${{ secrets.VPC_ID }} | |
SECURITY_GROUP_ID: ${{ secrets.SECURITY_GROUP_ID }} | |
RAYS_DB_WRITE_CONNECTION_STRING: ${{ secrets.RAYS_DB_WRITE_CONNECTION_STRING }} | |
RAYS_DB_READ_CONNECTION_STRING: ${{ secrets.RAYS_DB_READ_CONNECTION_STRING }} | |
BORROW_DB_READ_CONNECTION_STRING: ${{ secrets.BORROW_DB_READ_CONNECTION_STRING }} | |
CONFIG_URL: ${{ secrets.CONFIG_URL }} | |
CONFIG_URL_RAYS: ${{ secrets.CONFIG_URL_RAYS }} | |
steps: | |
- name: Send start notification to Discord | |
uses: Ilshidur/action-discord@0.3.2 | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SDK_DEPLOY }} | |
DISCORD_EMBEDS: | |
'[{"title":"Link to GitHub Action: | |
${{github.run_id}}","url":"https://github.com/${{github.repository}}/actions/runs/${{github.run_id | |
}}"}]' | |
with: | |
args: | |
'SDK deployment `${{github.run_id}}` started on staging 🚀 (from branch `${{ | |
github.ref_name }}` by [${{github.triggering_actor | |
}}](https://github.com/${{github.triggering_actor }})).' | |
- name: Git clone the repository | |
uses: actions/checkout@v3 | |
- name: Set up turbo cache | |
uses: rharkor/caching-for-turbo@v1.5 | |
- uses: pnpm/action-setup@v2.0.1 | |
with: | |
version: 8.14.1 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE }} | |
# role-duration-seconds: 14390 #adjust as needed for your build time | |
aws-region: ${{ secrets.AWS_REGION }} | |
- name: Install dependencies | |
run: pnpm install | |
- name: Prebuild | |
run: pnpm prebuild:sdk | |
- name: Build | |
run: pnpm build:sdk | |
- name: Deploy app | |
run: | | |
pnpm run sst:deploy:sdk:staging | |
- name: Send success notification to Discord | |
uses: Ilshidur/action-discord@0.3.2 | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SDK_DEPLOY }} | |
with: | |
args: 'SDK deployment `${{github.run_id}}` finished successfully on staging 🎉' | |
- name: Send failure notification to Discord | |
if: failure() | |
uses: Ilshidur/action-discord@0.3.2 | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SDK_DEPLOY }} | |
with: | |
args: 'SDK deployment `${{github.run_id}}` failed on staging ❌' | |
- name: Send cancellation notification to Discordz | |
if: cancelled() | |
uses: Ilshidur/action-discord@0.3.2 | |
env: | |
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_SDK_DEPLOY }} | |
with: | |
args: 'SDK deployment `${{github.run_id}}` was cancelled 🚫' | |
- name: Trigger e2e tests in e2e-tests repository | |
env: | |
E2E_TESTS_PAT: ${{ secrets.E2E_TESTS_PAT }} | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ env.E2E_TESTS_PAT }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/OasisDEX/e2e-tests/actions/workflows/ci_e2e_tests.yml/dispatches \ | |
-d "{\"ref\":\"main\", \"inputs\":{\"run_id\":\"${{ github.run_id }}\", \"repository\":\"${{ github.repository }}\"}}" | |
echo 'See test results in https://github.com/OasisDEX/e2e-tests/actions/workflows/ci_e2e_tests.yml --> Job with RUN_ID ${{ github.run_id }} in the logs.' |