diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 6f7ea0caf..a4bfcfed3 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -7,6 +7,7 @@ on: push: branches: - main + workflow_dispatch: permissions: contents: read @@ -46,7 +47,6 @@ jobs: run: yarn ${{ matrix.command }} build: - if: ${{ github.event_name == 'push' && github.ref_type == 'branch' }} runs-on: ubuntu-20.04 name: Build steps: @@ -161,55 +161,15 @@ jobs: - is_release: false environment: MAINNET environment: ${{ matrix.environment }} - runs-on: ubuntu-20.04 + runs-on: [self-hosted, Default, testnet] name: Deploy to ${{ matrix.environment }} steps: - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 + uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Authenticate to Google Cloud - uses: google-github-actions/auth@f105ef0cdb3b102a020be1767fcc8a974898b7c6 - with: - workload_identity_provider: ${{ secrets[format('{0}_{1}', matrix.environment, 'GCP_WORKLOAD_IDENTITY_PROVIDER')] }} - service_account: ${{ secrets[format('{0}_{1}', matrix.environment, 'GCP_WORKLOAD_IDENTITY_SERVICE_ACCOUNT')] }} - - name: Set Up Google Cloud SDK - uses: google-github-actions/setup-gcloud@e30db14379863a8c79331b04a9969f4c1e225e0b - - name: Get GKE Credentials - uses: google-github-actions/get-gke-credentials@35ab0d2b2d48792c19f09325413bd185c8d44394 - with: - cluster_name: ${{ secrets[format('{0}_{1}', matrix.environment, 'GKE_CLUSTER_NAME')] }} - location: ${{ secrets[format('{0}_{1}', matrix.environment, 'GKE_LOCATION')] }} - use_internal_ip: true - - name: Tunneling SSH connections - run: | - gcloud compute ssh ${{ secrets[format('{0}_{1}', matrix.environment, 'GCE_BASTION_INSTANCE_NAME')] }} \ - --project=${{ secrets[format('{0}_{1}', matrix.environment, 'GCP_PROJECT_ID')] }} \ - --zone ${{ secrets[format('{0}_{1}', matrix.environment, 'GCE_BASTION_INSTANCE_ZONE')] }} \ - --ssh-flag '-4 -L 8888:127.0.0.1:8888 -N -q -f' \ - --tunnel-through-iap \ - --quiet - - name: Set Up Helm - uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 - with: - version: v3.10.0 - - name: Perform Deployment - run: | - helm repo add myriadsocial https://charts.myriad.social - helm repo update - HTTPS_PROXY=127.0.0.1:8888 helm upgrade ${{ github.event.repository.name }} myriadsocial/myriad-api \ - --install \ - --set-string image.tag=${{ needs.release-please.outputs.tag_name || github.sha }} \ - --set-string serviceAccount.name=${{ github.event.repository.name }} \ - --set-string serviceAccount.annotations.'iam\.gke\.io/gcp-service-account'=${{ github.event.repository.name }}@${{ secrets[format('{0}_{1}', matrix.environment, 'GCP_PROJECT_ID')] }}.iam.gserviceaccount.com \ - --set config.secretsStore.enabled=true \ - --set-string config.secretsStore.providerClass=${{ github.event.repository.name }}-secrets-store-provider \ - --set-string config.secretsStore.name=${{ github.event.repository.name }}-secrets-store \ - --set-string nodeSelector.node_pool=general \ - --set-string nodeSelector.'iam\.gke\.io/gke-metadata-server-enabled'='true' - HTTPS_PROXY=127.0.0.1:8888 kubectl rollout status deployment/${{ github.event.repository.name }} - - name: Clean Up Tunneling SSH Connections - if: always() + - name: Update Docker Compose File run: | - kill -9 $(lsof -ti:8888) - gcloud compute os-login ssh-keys remove --key-file=/home/runner/.ssh/google_compute_engine.pub + sed -i "s|myriadsocial/myriad-api:.*|myriadsocial/myriad-api:${{ github.sha }}|" /home/$USER/docker-compose.yml + - name: Deploy Updated Compose + run: sudo systemctl restart myriad-social.service \ No newline at end of file diff --git a/.maintain/deployment/docker-compose.yaml b/.maintain/deployment/docker-compose.yaml index f51bb411f..8e414063c 100644 --- a/.maintain/deployment/docker-compose.yaml +++ b/.maintain/deployment/docker-compose.yaml @@ -28,39 +28,6 @@ services: networks: default: - api: &api - container_name: api - image: myriadsocial/myriad-api:${API_VERSION:-latest} - restart: always - environment: - - WAIT_HOSTS=mongo:27017 - - DOMAIN=${DOMAIN} - - MYRIAD_ADMIN_SUBSTRATE_MNEMONIC=${MYRIAD_ADMIN_SUBSTRATE_MNEMONIC} - - MYRIAD_ADMIN_NEAR_MNEMONIC=${MYRIAD_ADMIN_NEAR_MNEMONIC} - - JWT_TOKEN_SECRET_KEY=${JWT_TOKEN_SECRET_KEY} - - JWT_REFRESH_TOKEN_SECRET_KEY=${JWT_REFRESH_TOKEN_SECRET_KEY} - - MONGO_HOST=mongo - - MONGO_USER=${MONGO_USER} - - MONGO_PASSWORD=${MONGO_PASSWORD} - - MONGO_DATABASE=admin - - REDIS_CONNECTOR=kv-redis - - REDIS_HOST=redis - - REDIS_PASSWORD=${REDIS_PASSWORD} - - SMTP_SERVER=${SMTP_SERVER} - - SMTP_PORT=${SMTP_PORT} - - SMTP_USERNAME=${SMTP_USERNAME} - - SMTP_PASSWORD=${SMTP_PASSWORD} - - SMTP_SENDER_ADDRESS=${SMTP_USERNAME} - volumes: - - ../../.local/storages:/app/storages - ports: - - 3000:3000 - networks: - default: - depends_on: - - mongo - - redis - db_migration: <<: *api container_name: db_migration