feat: refactor city emissions retrieval to support all GPC scopes and… #4
This file contains hidden or 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: MCP Global API Deployment | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '**' | |
| - '.github/workflows/backend.yml' | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ghcr.io/open-earth-foundation/mcp-global-api | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_tag: ${{ steps.vars.outputs.commit_hash }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Git commit hash | |
| id: vars | |
| run: echo "commit_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Build and push image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| platforms: linux/amd64 | |
| tags: | | |
| ${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.commit_hash }} | |
| ${{ env.IMAGE_NAME }}:latest | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_EKS_DEV_USER }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_EKS_DEV_USER }} | |
| EKS_DEV_NAME: ${{ secrets.EKS_DEV_NAME }} | |
| IMAGE_TAG: ${{ needs.build.outputs.image_tag }} | |
| IMAGE_NAME: ghcr.io/open-earth-foundation/mcp-global-api | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_EKS_DEV_USER }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_EKS_DEV_USER }} | |
| aws-region: us-east-1 | |
| - name: Creating kubeconfig file | |
| run: aws eks update-kubeconfig --name "$EKS_DEV_NAME" --region us-east-1 | |
| - name: Testing connection to EKS | |
| run: kubectl get pods -n default | |
| - name: Apply Kubernetes manifests | |
| run: | | |
| kubectl apply -f k8s/mcp-deployment.yml | |
| kubectl apply -f k8s/mcp-service.yml | |
| - name: Update deployment image | |
| run: | | |
| kubectl set image deployment/mcp-global-api mcp-global-api=${IMAGE_NAME}:${IMAGE_TAG} -n default | |
| kubectl rollout status deployment/mcp-global-api -n default |