Skip to content

Commit

Permalink
ci(release): implement api deploy to akash
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Oct 14, 2024
1 parent a9fa7e8 commit dc5b6d1
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 8 deletions.
120 changes: 120 additions & 0 deletions .github/workflows/deploy-api-to-akash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Deploy API to Akash

on:
push:
tags:
- 'console-api/v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


env:
ORG: akash-network
REPO: provider
CLIENT: provider-services
CLIENT_VERSION: 0.6.4
ARCH: linux_amd64
NET: mainnet
BLOCK_TIME: 1s
CHAIN_LATENCY: 30
AKASH_KEYRING_BACKEND: file
AKASH_BROADCAST_MODE: block
AKASH_YES: 1
AKASH_GAS_PRICES: 0.025uakt
AKASH_GAS: auto
AKASH_GAS_ADJUSTMENT: 1.5
AKASH_HOME: /home/runner/.akash
AKASH_FROM: default
AKASH_OUTPUT: json
MIN_BALANCE: 10
AKASH_GSEQ: 1
AKASH_OSEQ: 1
SDL: deploy.yaml
PARSED_SDL: ${{ github.workspace }}/${{ inputs.project-path }}/deploy-parsed.yaml
PROVIDER: ${{inputs.provider}}
SQL_PROXY_AUTH_TOKEN: ${{secrets.SQL_PROXY_AUTH_TOKEN}}

jobs:
define-vars:
name: Define Variables
runs-on: ubuntu-latest

permissions:
contents: write
packages: write

outputs:
app: ${{ steps.vars.outputs.app }}
image: ${{ steps.vars.outputs.image }}
workspace: ${{ steps.vars.outputs.workspace }}
steps:
- name: Set app name
id: vars
env:
API_REGISTRY: ${{ vars.API_REGISTRY }}
run: |
API_WORKSPACE="apps/api"
FULL_TAG="${{ github.ref_name }}"
IFS='/' read -r scope version <<< "$FULL_TAG"
prerelease_type=$(echo "$version" | sed -n 's/.*-\([a-zA-Z]*\).*/\1/p')
app="${scope#console-}"
registry_var="$(echo "$app" | tr '[:lower:]' '[:upper:]')_REGISTRY"
registry="${!registry_var}"
workspace_var="$(echo "$app" | tr '[:lower:]' '[:upper:]')_WORKSPACE"
workspace="${!workspace_var}"
app="${scope#console-}-${prerelease_type:-stable}"
version="${version#v}"
image="$registry:$version"
echo "workspace=${workspace}"
echo "app=${app}"
echo "image=${image}"
echo "workspace=${workspace}" >> $GITHUB_OUTPUT
echo "app=${app}" >> $GITHUB_OUTPUT
echo "image=${image}" >> $GITHUB_OUTPUT

deploy-sandbox:
needs: define-vars
runs-on: ubuntu-latest
steps:
- name: Deploy Sandbox
uses: akash-network/akash-deploy-action/.github/actions/deploy@main
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_API_STAGING_SANDBOX_TOKEN }}
API_DOMAIN: ${{ vars.API_SANDBOX_STAGING_DOMAIN }}
with:
project-path: ${{ needs.define-vars.outputs.workspace }}
project-name: ${{ needs.define-vars.outputs.app }}-sandbox
image: ${{ needs.define-vars.outputs.image }}
provider: ${{ vars.AKASH_PROVIDER }}
seed: ${{ secrets.WALLET_MNEMONIC }}
password: ${{ secrets.WALLET_PASSWORD }}
github-author-email: "[email protected]"
github-author-name: "Akash Network Team"
github-token: ${{ secrets.GITHUB_TOKEN }}

deploy-mainnet:
needs: [define-vars,deploy-sandbox]
runs-on: ubuntu-latest
steps:
- name: Deploy Mainnet
uses: akash-network/akash-deploy-action/.github/actions/deploy@main
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_API_STAGING_MAINNET_TOKEN }}
API_DOMAIN: ${{ vars.API_MAINNET_STAGING_DOMAIN }}
with:
project-path: ${{ needs.define-vars.outputs.workspace }}
project-name: ${{ needs.define-vars.outputs.app }}-mainnet
image: ${{ needs.define-vars.outputs.image }}
provider: ${{ vars.AKASH_PROVIDER }}
password: ${{ secrets.WALLET_PASSWORD }}
seed: ${{ secrets.WALLET_MNEMONIC }}
github-author-email: "[email protected]"
github-author-name: "Akash Network Team"
github-token: ${{ secrets.GITHUB_TOKEN }}
3 changes: 1 addition & 2 deletions .github/workflows/release-all-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.AKASH_GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -45,8 +46,6 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build the Docker images
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "Akash Network Team"
Expand Down
12 changes: 6 additions & 6 deletions apps/api/deploy.yml → apps/api/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ version: "2.0"

services:
api:
image: <IMAGE_NAME>:<IMAGE_TAG>
image: {{IMAGE_NAME}}
depends-on: cloud-sql-proxy
env:
- DOPPLER_TOKEN=
- SENTRY_SERVER_NAME=
- DOPPLER_TOKEN={{DOPPLER_TOKEN}}
- SENTRY_SERVER_NAME=akash
expose:
- port: 3080
as: 80
accept:
- console-api-sandbox-staging.akash.network
- {{API_DOMAIN}}
to:
- global: true
cloud-sql-proxy:
image: redm4x/cloud-sql-proxy:1.31.2
env:
- KeyPath=/custom/proxy_key.json
- ConnectionName=cloudmos-explorer:us-central1:cloudmos-postgresql
- Token=<AUTH>
- Token={{SQL_PROXY_AUTH_TOKEN}}
command:
- "sh"
- "-c"
Expand All @@ -47,7 +47,7 @@ profiles:
cpu:
units: 0.5
memory:
size: 512mi
size: 512Mi
storage:
size: 2Gi
placement:
Expand Down

0 comments on commit dc5b6d1

Please sign in to comment.