@@ -17,63 +17,196 @@ env:
1717 REGISTRY : gcr.io/linen-analyst-344721
1818 DOCKER_REPOSITORY_OWNER : ${{ github.repository_owner }}
1919 GITOPS_REPO : speakeasy-api/gram-infra
20- GITOPS_BRANCH : main
20+ GITOPS_BRANCH : staging
2121 ENVIRONMENT : dev
2222
2323jobs :
24- build-and-deploy :
24+ changes :
25+ name : Tag branch changes
2526 runs-on : ubicloud-standard-4
27+ permissions :
28+ contents : " read"
29+ pull-requests : read
2630 outputs :
27- server-image-tag : ${{ steps.build-server .outputs.image-tag }}
28- dashboard-image-tag : ${{ steps.build-dashboard .outputs.image-tag }}
31+ server : ${{ steps.gates .outputs.server }}
32+ client : ${{ steps.gates .outputs.client }}
2933 steps :
34+ - name : Checkout source code
35+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
36+ - uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
37+ name : Check for changed packages
38+ id : filter
39+ with :
40+ filters : .github/filters.yaml
41+ - id : gates
42+ name : Set outputs
43+ run : |
44+ if [[ "${{ steps.filter.outputs.server }}" == "true" || "${{ github.ref }}" == "refs/heads/main" ]]; then
45+ echo "server=true" >> $GITHUB_OUTPUT
46+ echo "Server jobs will run."
47+ else
48+ echo "Server jobs will be skipped."
49+ fi
50+
51+ if [[ "${{ steps.filter.outputs.client }}" == "true" || "${{ github.ref }}" == "refs/heads/main" ]]; then
52+ echo "client=true" >> $GITHUB_OUTPUT
53+ echo "Client jobs will run."
54+ else
55+ echo "Client jobs will be skipped."
56+ fi
57+
58+ build-and-deploy-dashboard :
59+ name : " Build and Deploy Dashboard"
60+ runs-on : ubicloud-standard-4
61+ needs : changes
62+ env :
63+ GRAM_GIT_SHA : " ${{ github.sha }}"
64+ steps :
65+ - name : Skip if no client changes exist
66+ if : ${{ needs.changes.outputs.client != 'true' }}
67+ run : echo "No client changes detected — skipping client-build-lint-test job."
68+
3069 - name : Checkout
31- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
70+ if : ${{ needs.changes.outputs.client == 'true' }}
71+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
72+
73+ - name : Setup Mise
74+ if : ${{ needs.changes.outputs.client == 'true' }}
75+ uses : jdx/mise-action@5ac50f778e26fac95da98d50503682459e86d566 # v3.2.0
76+ with :
77+ install : true
78+ cache : true
79+ env : false
80+
81+ - name : Prepare GitHub Actions environment
82+ if : ${{ needs.changes.outputs.client == 'true' }}
83+ run : mise run github
3284
33- - name : Authenticate to Google Cloud
34- id : auth
35- uses : google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5
85+ - name : Cache PNPM
86+ if : ${{ needs.changes.outputs.client == 'true' }}
87+ uses : actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
88+ with :
89+ key : ${{ env.GH_CACHE_PNPM_KEY }}
90+ restore-keys : |
91+ ${{ env.GH_CACHE_PNPM_KEY }}
92+ ${{ env.GH_CACHE_PNPM_KEY_PARTIAL }}
93+ path : |
94+ ${{ env.PNPM_STORE_PATH }}
95+
96+ - name : Install dependencies
97+ if : ${{ needs.changes.outputs.client == 'true' }}
98+ run : pnpm install --frozen-lockfile
99+
100+ - name : Build
101+ if : ${{ needs.changes.outputs.client == 'true' }}
102+ env :
103+ NODE_ENV : production
104+ run : mise exec --env viteprod -- pnpm build
105+
106+ - name : Upload source maps to DataDog
107+ if : ${{ needs.changes.outputs.client == 'true' }}
108+ env :
109+ DATADOG_API_KEY : ${{ secrets.DATADOG_API_KEY }}
110+ run : mise run datadog:sourcemaps --git-sha "${{ github.sha }}"
111+
112+ - name : Lint
113+ if : ${{ needs.changes.outputs.client == 'true' }}
114+ run : pnpm lint
115+ working-directory : client/dashboard
116+
117+ - name : Check for dirty files
118+ if : ${{ needs.changes.outputs.client == 'true' }}
119+ run : mise run git:porcelain
120+
121+ - id : " auth"
122+ if : needs.changes.outputs.client == 'true'
123+ name : " Authenticate to Google Cloud"
124+ uses : google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
36125 with :
37126 token_format : " access_token"
38127 workload_identity_provider : " projects/409661704476/locations/global/workloadIdentityPools/ga-pool/providers/github-oidc-provider"
39128 service_account : " speakeasy-registry-ga-ci@linen-analyst-344721.iam.gserviceaccount.com"
40129
41130 - name : Login to GCR
42- uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
131+ if : needs.changes.outputs.client == 'true'
132+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
43133 with :
44134 registry : gcr.io/linen-analyst-344721
45135 username : oauth2accesstoken
46136 password : ${{ steps.auth.outputs.access_token }}
47137
48- - name : Build and Push Server Image
49- id : build-server
138+ - name : Build and Push Registry image to GCR
139+ id : build
140+ if : needs.changes.outputs.client == 'true'
50141 uses : ./.github/workflows/composite/build-push
51142 with :
52143 registry : ${{ env.REGISTRY }}
53144 username : oauth2accesstoken
54145 password : ${{ steps.auth.outputs.access_token }}
55- image : ${{ env.DOCKER_REPOSITORY_OWNER }}/gram
56- context : ./server
57- file : server /Dockerfile
146+ image : ${{ env.DOCKER_REPOSITORY_OWNER }}/gram-dashboard
147+ context : ./client/dashboard
148+ file : client/dashboard /Dockerfile
58149 git-auth-token : ${{ secrets.BOT_REPO_TOKEN }}
59- build-args : |
60- GIT_USERNAME=speakeasybot
61150
62- - name : Build and Push Dashboard Image
63- id : build-dashboard
151+ - name : Prune PNPM store
152+ if : ${{ needs.changes.outputs.client == 'true' && success() }}
153+ run : pnpm store prune
154+ build-and-deploy-server :
155+ name : " Build and Deploy Server"
156+ runs-on : ubicloud-standard-4
157+ needs : changes
158+ env :
159+ GOMAXPROCS : 4
160+ steps :
161+ - name : Skip if no server changes exist
162+ if : ${{ needs.changes.outputs.server != 'true' }}
163+ run : echo "No server changes detected — skipping server-build-lint job."
164+
165+ - name : Checkout
166+ if : ${{ needs.changes.outputs.server == 'true' }}
167+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
168+ - id : " auth"
169+ if : ${{ needs.changes.outputs.server == 'true' }}
170+ name : " Authenticate to Google Cloud"
171+ uses : google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
172+ with :
173+ token_format : " access_token"
174+ workload_identity_provider : " projects/409661704476/locations/global/workloadIdentityPools/ga-pool/providers/github-oidc-provider"
175+ service_account : " speakeasy-registry-ga-ci@linen-analyst-344721.iam.gserviceaccount.com"
176+ - name : Login to GCR
177+ if : ${{ needs.changes.outputs.server == 'true' }}
178+ uses : docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
179+ with :
180+ registry : gcr.io/linen-analyst-344721
181+ username : oauth2accesstoken
182+ password : ${{ steps.auth.outputs.access_token }}
183+ - name : Build and Push Registry image to GCR
184+ id : build
185+ if : ${{ needs.changes.outputs.server == 'true' }}
64186 uses : ./.github/workflows/composite/build-push
65187 with :
66188 registry : ${{ env.REGISTRY }}
67189 username : oauth2accesstoken
68190 password : ${{ steps.auth.outputs.access_token }}
69- image : ${{ env.DOCKER_REPOSITORY_OWNER }}/gram-dashboard
70- context : ./client/dashboard
71- file : client/dashboard /Dockerfile
191+ image : ${{ env.DOCKER_REPOSITORY_OWNER }}/gram
192+ context : ./server
193+ file : server /Dockerfile
72194 git-auth-token : ${{ secrets.BOT_REPO_TOKEN }}
195+ build-args : |
196+ GIT_USERNAME=speakeasybot
197+ - name : Pull and Run Image
198+ if : ${{ needs.changes.outputs.server == 'true' }}
199+ run : |
200+ echo "Pulling image: ${{ steps.build.outputs.image-tag }}"
201+ docker pull ${{ steps.build.outputs.image-tag }}
202+ echo "Running image..."
203+ docker run --rm ${{ steps.build.outputs.image-tag }} version
73204
74205 update-gitops-and-deploy :
75206 runs-on : ubicloud-standard-4
76- needs : build-and-deploy
207+ needs :
208+ - build-and-deploy-server
209+ - build-and-deploy-dashboard
77210 steps :
78211 - name : Checkout GitOps Repository
79212 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
0 commit comments