name: 'Deploy new squid and indexer' on: push: branches: - 'main' - 'idea-release' paths: - idea/explorer/** - idea/squid/** workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_REGION: ${{ secrets.AWS_REGION }} KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }} jobs: build-explorer-image: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set image tag id: tag run: | if [ "${{ github.ref }}" == "refs/heads/idea-release" ]; then echo "tag=prod" >> $GITHUB_ENV else echo "tag=qa" >> $GITHUB_ENV fi - name: Build and push Data Storage Docker image uses: docker/build-push-action@master with: file: idea/explorer/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-explorer:${{ env.tag }} build-squid-image: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v2 - name: Log in to the github container registry uses: docker/login-action@master with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Set image tag id: tag run: | if [ "${{ github.ref }}" == "refs/heads/idea-release" ]; then echo "tag=prod" >> $GITHUB_ENV else echo "tag=qa" >> $GITHUB_ENV fi - name: Build and push Api Gateway Docker image uses: docker/build-push-action@master with: file: idea/squid/Dockerfile push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-squid:${{ env.tag }} deploy-to-k8s: needs: - build-explorer-image - build-squid-image runs-on: ubuntu-latest steps: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ env.AWS_REGION }} - name: Set deployment variables id: vars run: | if [ "${{ github.ref }}" == "refs/heads/idea-release" ]; then echo "namespace=prod-idea" >> $GITHUB_ENV echo "deployments=explorer squid-testnet squid-mainnet" >> $GITHUB_ENV else echo "namespace=dev-1" >> $GITHUB_ENV echo "deployments=explorer squid-testnet" >> $GITHUB_ENV fi - name: Deploy to k8s uses: sergeyfilyanin/kubectl-aws-eks@master with: args: rollout restart deployment ${{ env.deployments }} -n ${{ env.namespace }} - name: Check k8s deployments uses: sergeyfilyanin/kubectl-aws-eks@master with: args: get deployment -o name -n ${{ env.namespace }} | xargs -n1 -t kubectl rollout status -n ${{ env.namespace }} --timeout=120s