Skip to content

feat(api): add legacy coingecko format (#544) #9

feat(api): add legacy coingecko format (#544)

feat(api): add legacy coingecko format (#544) #9

Workflow file for this run

name: Build and Deploy Docker Images
on:
push:
branches: ['main']
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
service:
[
api,
app,
app-lite,
backend,
indexer-balance,
indexer-base,
indexer-events,
indexer-dex,
explorer-selector,
aggregates,
]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker Login
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get short SHA
id: slug
run: echo "sha8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: apps/${{ matrix.service }}/Dockerfile
platforms: linux/amd64
push: true
tags: |
ghcr.io/nearblocks/${{ matrix.service }}:latest
ghcr.io/nearblocks/${{ matrix.service }}:${{ steps.slug.outputs.sha8 }}
cache-from: type=registry,ref=ghcr.io/nearblocks/${{ matrix.service }}:latest
cache-to: type=inline
- name: Set image digest output
id: set_output
run: |
if [[ "${{ steps.docker_build.outcome }}" == "success" ]]; then
echo "${{ matrix.service }}=ghcr.io/nearblocks/${{ matrix.service }}@$(echo ${{ steps.docker_build.outputs.digest }} | awk -F'@' '{print $2}')" >> $GITHUB_OUTPUT
else
echo "${{ matrix.service }} build failed" >> $GITHUB_OUTPUT
fi
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up kubectl
uses: azure/setup-kubectl@v3
with:
version: 'v1.28.0'
- name: Configure kubectl
run: |
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > kubeconfig
echo "KUBECONFIG=$(pwd)/kubeconfig" >> $GITHUB_ENV
- name: Update Kubernetes deployments
run: |

Check failure on line 91 in .github/workflows/build-deploy.yaml

View workflow run for this annotation

GitHub Actions / Build and Deploy Docker Images

Invalid workflow file

The workflow is not valid. .github/workflows/build-deploy.yaml (Line: 91, Col: 14): Unrecognized named-value: 'service'. Located at position 21 within expression: needs.build.outputs[service] .github/workflows/build-deploy.yaml (Line: 111, Col: 14): Unrecognized named-value: 'service'. Located at position 21 within expression: needs.build.outputs[service]
declare -A namespaces=(["testnet"]="nearblocks-testnet")
services=(api app app-lite backend indexer-balance indexer-base indexer-events indexer-dex explorer-selector aggregates)
for net in mainnet testnet; do
echo "Switching to namespace ${namespaces[$net]}"
kubectl config set-context --current --namespace=${namespaces[$net]}
for service in "${services[@]}"; do
if [[ -n "${{ needs.build.outputs[service] }}" ]]; then
deployment_name="$net-$service"
echo "Updating deployment for $deployment_name in ${namespaces[$net]}"
kubectl set image deployment/$deployment_name $service=${{ needs.build.outputs[service] }}
else
echo "Skipping deployment for $net-$service (no updates)"
fi
done
done
- name: Verify rollout
run: |
declare -A namespaces=(["testnet"]="nearblocks-testnet")
services=(api app app-lite backend indexer-balance indexer-base indexer-events indexer-dex explorer-selector aggregates)
for net in mainnet testnet; do
echo "Verifying rollouts in namespace ${namespaces[$net]}"
kubectl config set-context --current --namespace=${namespaces[$net]}
for service in "${services[@]}"; do
if [[ -n "${{ needs.build.outputs[service] }}" ]]; then
deployment_name="$net-$service"
echo "Verifying rollout for $deployment_name in ${namespaces[$net]}"
if ! kubectl rollout status deployment/$deployment_name --timeout=300s; then
echo "Rollout failed for $deployment_name in ${namespaces[$net]}"
failed_rollouts+=("$deployment_name in ${namespaces[$net]}")
fi
fi
done
done
- name: Rollback failed deployments
if: failure()
run: |
declare -A namespaces=(["testnet"]="nearblocks-testnet")
services=(api app app-lite backend indexer-balance indexer-base indexer-events indexer-dex explorer-selector aggregates)
for net in mainnet testnet; do
echo "Checking for failed deployments in namespace ${namespaces[$net]}"
kubectl config set-context --current --namespace=${namespaces[$net]}
for service in "${services[@]}"; do
if [[ -n "${{ needs.build.outputs[service] }}" ]]; then
deployment_name="$net-$service"
echo "Attempting rollback for $deployment_name in ${namespaces[$net]}"
kubectl rollout undo deployment/$deployment_name
fi
done
done
- name: Notify on failure
if: failure()
run: |
echo "Deployment failed. Manual intervention may be required."