Skip to content

Commit

Permalink
(core) cicd registry caching (#757)
Browse files Browse the repository at this point in the history
* add registry caching

* add deployment step summary

* fix caching

* fix cicd docs

* add deployment step summary to docs deploy
  • Loading branch information
maxmwang authored Jan 4, 2025
1 parent 1cc4477 commit 19e452e
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 10 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/cd-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ jobs:
image: [backend, frontend]

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Image with Tag
run: |
docker build --no-cache --platform=linux/amd64 --target ${{ matrix.image }}-prod --tag "${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.image_tag }}" .
docker push "${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.image_tag }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and Push
uses: docker/build-push-action@v6
with:
target: ${{ matrix.image }}-prod
tags: ${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.image_tag }}
cache-from: |
type=registry,ref=${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.image_tag }}-cache
type=registry,ref=${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:prod-cache
cache-to: type=registry,ref=${{ secrets.DOCKER_USERNAME }}/bt-${{ matrix.image }}:${{ inputs.image_tag }}-cache,mode=max
platforms: linux/amd64
push: true

build-push-chart:
name: Build and Push Helm Chart
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/cd-deploy-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
- name: Build and Push
uses: docker/build-push-action@v6
with:
context: docs
Expand Down Expand Up @@ -89,3 +89,7 @@ jobs:
# Check container status
kubectl rollout status --timeout=180s deployment bt-prod-docs-docs
- name: Output Summary
run: |
echo "# :white_check_mark: Deployment available at [docs.stanfurdtime.com](https://docs.stanfurdtime.com)." >> $GITHUB_STEP_SUMMARY
8 changes: 8 additions & 0 deletions .github/workflows/cd-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
description: "Helm chart version"
required: true
type: string
host:
description: "Hostname for the deployment"
required: true
type: string
values:
description: "Helm chart override values (yaml)"
required: true
Expand Down Expand Up @@ -55,3 +59,7 @@ jobs:
# Check container status
kubectl rollout status --timeout=180s deployment ${{ inputs.name }}-backend
kubectl rollout status --timeout=180s deployment ${{ inputs.name }}-frontend
- name: Output Summary
run: |
echo "# :white_check_mark: Deployment available at [${{ inputs.host }}](https://${{ inputs.host }})." >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
host: ${{ needs.compute-sha.outputs.sha_short }}.dev.stanfurdtime.com
mongoUri: mongodb://bt-dev-mongo-mongodb-0.bt-dev-mongo-mongodb-headless.bt.svc.cluster.local:27017/bt
redisUri: redis://bt-dev-redis-master.bt.svc.cluster.local:6379
host: ${{ needs.compute-sha.outputs.sha_short }}.dev.stanfurdtime.com
secrets: inherit

limit-deploy:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cd-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
version: "1.0.0"
values: |
host: stanfurdtime.com
host: stanfurdtime.com
secrets: inherit
1 change: 1 addition & 0 deletions .github/workflows/cd-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ jobs:
host: staging.stanfurdtime.com
mongoUri: mongodb://bt-stage-mongo-mongodb.bt.svc.cluster.local:27017/bt
redisUri: redis://bt-stage-redis-master.bt.svc.cluster.local:6379
host: staging.stanfurdtime.com
# TODO(core): change mongoUri to replicaset
secrets: inherit
1 change: 0 additions & 1 deletion docs/src/core/infrastructure/cicd-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ The differences between the three environments are managed by each individual wo
[^2]: Development, Staging, and Production

[^3]: Ideally, these would follow [semantic versioning](https://semver.org/), but this is rather difficult to enforce and automate.

Binary file added docs/src/getting-started/assets/cicd-dev-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/src/getting-started/deployment-with-cicd.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The deployment process is different for [development](#development), [staging](#

</details>

5. After the action succeeds, go to `www.abcdefg.dev.stanfurdtime.com`, where `abcdefg` is the first 7 characters of the latest commit's hash. This is also shown on the summary tab of an action workflow.
5. After the action succeeds, go to `www.abcdefg.dev.stanfurdtime.com`, where `abcdefg` is the first 7 characters of the latest commit's hash. This is also shown on the summary tab of an action workflow. A hyperlink to the deployment is also available near the bottom of the Summary page of the workflow run.

<details><summary>Example Success Deployment Log</summary>

Expand Down Expand Up @@ -68,6 +68,8 @@ The deployment process is different for [development](#development), [staging](#
===============================================
```
![Deploy to Development Link](./assets/cicd-dev-6.png)
</details>
## Staging
Expand Down

0 comments on commit 19e452e

Please sign in to comment.