Skip to content

Commit ff3edee

Browse files
authored
infra/ci: Add GitHub Actions workflow for staging and production deployment (#256)
## Motivation and Context - Enable all contributors to manage the infrastructure - Enable deployments without error-prone manual intervention ## How Has This Been Tested? Tested by deploying from this test branch, getting CI green and seeing changes were applied ## Breaking Changes <!-- Will users need to update their code or configurations? --> ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [ ] I have added or updated documentation as needed
1 parent 1b8f7a6 commit ff3edee

File tree

3 files changed

+100
-10
lines changed

3 files changed

+100
-10
lines changed

.github/workflows/deploy.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
PULUMI_VERSION: "3.188.0"
10+
GO_VERSION: "1.24.6"
11+
12+
jobs:
13+
deploy-staging:
14+
name: Deploy to Staging
15+
runs-on: ubuntu-latest
16+
environment: staging
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: ${{ env.GO_VERSION }}
25+
26+
- name: Setup Pulumi
27+
uses: pulumi/actions@v6
28+
with:
29+
pulumi-version: ${{ env.PULUMI_VERSION }}
30+
31+
- name: Authenticate to Google Cloud
32+
uses: google-github-actions/auth@v2
33+
with:
34+
credentials_json: ${{ secrets.GCP_STAGING_SERVICE_ACCOUNT_KEY }}
35+
36+
- name: Setup Google Cloud SDK
37+
uses: google-github-actions/setup-gcloud@v2
38+
with:
39+
project_id: mcp-registry-staging
40+
install_components: gke-gcloud-auth-plugin
41+
42+
- name: Deploy to Staging
43+
working-directory: ./deploy
44+
run: |
45+
echo "${{ secrets.PULUMI_STAGING_PASSPHRASE }}" > passphrase.staging.txt
46+
make staging-up
47+
48+
deploy-production:
49+
name: Deploy to Production
50+
runs-on: ubuntu-latest
51+
environment: production
52+
needs: deploy-staging
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Setup Go
58+
uses: actions/setup-go@v5
59+
with:
60+
go-version: ${{ env.GO_VERSION }}
61+
62+
- name: Setup Pulumi
63+
uses: pulumi/actions@v6
64+
with:
65+
pulumi-version: ${{ env.PULUMI_VERSION }}
66+
67+
- name: Authenticate to Google Cloud
68+
uses: google-github-actions/auth@v2
69+
with:
70+
credentials_json: ${{ secrets.GCP_PROD_SERVICE_ACCOUNT_KEY }}
71+
72+
- name: Setup Google Cloud SDK
73+
uses: google-github-actions/setup-gcloud@v2
74+
with:
75+
project_id: mcp-registry-prod
76+
install_components: gke-gcloud-auth-plugin
77+
78+
- name: Deploy to Production
79+
working-directory: ./deploy
80+
run: |
81+
echo "${{ secrets.PULUMI_PROD_PASSPHRASE }}" > passphrase.prod.txt
82+
make prod-up

deploy/Makefile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help build local-preview local-up staging-preview staging-up prod-preview prod-up
1+
.PHONY: help build local-login local-preview local-up staging-login staging-preview staging-up prod-login prod-preview prod-up
22

33
# Default target
44
help: ## Show this help message
@@ -10,22 +10,31 @@ build: ## Build the Pulumi Go program
1010
go build
1111

1212
# Local stack commands
13-
local-preview: build ## Preview local infrastructure changes
13+
local-login: ## Login to local Pulumi backend
14+
pulumi login --local
15+
16+
local-preview: build local-login ## Preview local infrastructure changes
1417
PULUMI_CONFIG_PASSPHRASE="" pulumi preview --stack local
1518

16-
local-up: build ## Deploy local infrastructure
19+
local-up: build local-login ## Deploy local infrastructure
1720
PULUMI_CONFIG_PASSPHRASE="" pulumi up --yes --stack local
1821

1922
# Staging stack commands
20-
staging-preview: build ## Preview staging infrastructure changes
23+
staging-login: ## Login to staging Pulumi backend
24+
pulumi login gs://mcp-registry-staging-pulumi-state
25+
26+
staging-preview: build staging-login ## Preview staging infrastructure changes
2127
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.staging.txt pulumi preview --stack gcpStaging
2228

23-
staging-up: build ## Deploy staging infrastructure
29+
staging-up: build staging-login ## Deploy staging infrastructure
2430
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.staging.txt pulumi up --yes --stack gcpStaging
2531

2632
# Production stack commands
27-
prod-preview: build ## Preview production infrastructure changes
33+
prod-login: ## Login to production Pulumi backend
34+
pulumi login gs://mcp-registry-prod-pulumi-state
35+
36+
prod-preview: build prod-login ## Preview production infrastructure changes
2837
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.prod.txt pulumi preview --stack gcpProd
2938

30-
prod-up: build ## Deploy production infrastructure
39+
prod-up: build prod-login ## Deploy production infrastructure
3140
PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.prod.txt pulumi up --yes --stack gcpProd

deploy/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Pre-requisites:
2929
3030
### Production Deployment (GCP)
3131
32-
**Note:** This is how the production deployment will be set up once. But then the plan will be future updates are effectively a login + `pulumi up` from GitHub Actions.
32+
**Note:** The production deployment is automatically handled by GitHub Actions. All merges to the `main` branch trigger an automatic deployment to GCP via [the configured GitHub Actions workflow](../.github/workflows/deploy.yml). The steps below are preserved as a log of what we did, or if a manual override is needed.
3333
3434
Pre-requisites:
3535
- [Pulumi CLI installed](https://www.pulumi.com/docs/iac/download-install/)
@@ -51,8 +51,7 @@ Pre-requisites:
5151
```
5252
5. Create a GCS bucket for Pulumi state: `gsutil mb gs://mcp-registry-prod-pulumi-state`
5353
6. Set Pulumi's backend to GCS: `pulumi login gs://mcp-registry-prod-pulumi-state`
54-
7. Get the passphrase file `passphrase.prod.txt` from @domdomegg
55-
- TODO: avoid dependence on one person! Probably will shift all of this into CI.
54+
7. Get the passphrase file `passphrase.prod.txt` from the registry maintainers
5655
8. Init the GCP stack: `PULUMI_CONFIG_PASSPHRASE_FILE=passphrase.prod.txt pulumi stack init gcpProd`
5756
9. Set the GCP credentials in Pulumi config:
5857
```bash

0 commit comments

Comments
 (0)