Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 47 additions & 43 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,37 @@ on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Image tag to deploy
required: true
type: string

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

env:
TAG: ${{ github.event.release.tag_name || github.sha }}
REPOSITORY: mcp-for-docs
ENVIRONMENT: production
PROJECT: mcp-for-docs
DECLARATIVE_OWNER: appwrite-labs
DECLARATIVE_REPOSITORY: assets-applications
REGISTRY_GITHUB: ghcr.io
IMAGE_NAME: appwrite/mcp-for-docs
TAG: ${{ github.event.release.tag_name || inputs.tag }}

jobs:
build:
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Login to GHCR
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.REGISTRY_GITHUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -28,52 +43,41 @@ jobs:
with:
context: .
push: true
tags: ghcr.io/appwrite/mcp-for-docs:${{ env.TAG }}
tags: ${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
secrets: |
OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
Comment thread
greptile-apps[bot] marked this conversation as resolved.

deploy_kubernetes:
strategy:
matrix:
region: [{ full: fra1, short: fra }]
deploy:
needs: build
if: always() && (needs.build.result == 'success' || needs.build.result == 'skipped')
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@v4
- name: Install Kubectl
uses: azure/setup-kubectl@v4
- name: Install Helm
uses: azure/setup-helm@v4
- name: Install doctl
uses: digitalocean/action-doctl@v2
- name: Get token for ${{ env.DECLARATIVE_REPOSITORY }}
id: app-token
uses: actions/create-github-app-token@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 assets-${{ matrix.region.full }}-prod

- name: Ensure namespaces exist
run: |
kubectl create namespace mcp-for-docs --dry-run=client -o yaml | kubectl apply -f -
app-id: ${{ vars.DECLARATIVE_DEPLOYMENT_GITHUB_APP_ID }}
private-key: ${{ secrets.DECLARATIVE_DEPLOYMENT_GITHUB_APP_PRIVATE_KEY }}
owner: ${{ env.DECLARATIVE_OWNER }}
repositories: ${{ env.DECLARATIVE_REPOSITORY }}

- name: Create docker pull secret
run: |
kubectl -n mcp-for-docs create secret docker-registry ghcr \
--docker-server=ghcr.io \
--docker-username="${{ secrets.GHCR_USERNAME }}" \
--docker-password="${{ secrets.GHCR_TOKEN }}" \
--docker-email=ci@appwrite.io \
--dry-run=client -o yaml | kubectl apply -f -
- name: Checkout ${{ env.DECLARATIVE_REPOSITORY }}
uses: actions/checkout@v6
with:
repository: ${{ env.DECLARATIVE_OWNER }}/${{ env.DECLARATIVE_REPOSITORY }}
token: ${{ steps.app-token.outputs.token }}

- name: Create application secrets
run: |
kubectl -n mcp-for-docs create secret generic mcp-for-docs \
--from-literal=openai-api-key="${{ secrets.OPENAI_API_KEY }}" \
--dry-run=client -o yaml | kubectl apply -f -
- name: Update image tag
run: yq -i '.global.image.tag = strenv(TAG)' ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml

- name: Deploy
- name: Commit and push
run: |
helm upgrade --install --namespace mcp-for-docs mcp-for-docs deploy/mcp-for-docs/ \
--values deploy/mcp-for-docs/environments/production/${{ matrix.region.full }}.values.yaml \
--set imagePullSecret='ghcr' \
--set version=${{ env.TAG }}
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "chore(${ENVIRONMENT}): ${PROJECT} image tag to ${TAG}"
git push
fi
Comment thread
greptile-apps[bot] marked this conversation as resolved.