Production deployment #8
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: Production deployment | |
| 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: | |
| 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@v6 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY_GITHUB }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ env.REGISTRY_GITHUB }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} | |
| secrets: | | |
| OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} | |
| deploy: | |
| needs: build | |
| if: always() && (needs.build.result == 'success' || needs.build.result == 'skipped') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get token for ${{ env.DECLARATIVE_REPOSITORY }} | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| 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: Checkout ${{ env.DECLARATIVE_REPOSITORY }} | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ env.DECLARATIVE_OWNER }}/${{ env.DECLARATIVE_REPOSITORY }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Update image tag | |
| run: yq -i '.global.image.tag = strenv(TAG)' ${{ env.ENVIRONMENT }}/${{ env.PROJECT }}/default.yaml | |
| - name: Commit and push | |
| run: | | |
| 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 |