From 7fda80140d7708ea1640e54706c8a3f23fd86e31 Mon Sep 17 00:00:00 2001 From: Mubangizi Allan Date: Fri, 12 Jun 2026 10:10:39 +0300 Subject: [PATCH 1/2] move deployment server to renu --- .github/workflows/prod.yml | 226 +++++++++++++++++++------------------ scripts/deployment.yml | 48 ++++++++ 2 files changed, 162 insertions(+), 112 deletions(-) create mode 100644 scripts/deployment.yml diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index 30f3afb..f6735af 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -1,116 +1,118 @@ -name: Production Deployment +name: Production deployment on: - push: - branches: - - main - release: - types: - - released - - prereleased + push: + branches: + - main + - ch-update-deployment + release: + types: + - released + - prereleased jobs: - build_and_deploy: - outputs: - image: ${{ steps.export.outputs.image }} - tag: ${{ steps.export.outputs.tag }} - release_version: ${{ steps.version.outputs.version }} - - runs-on: ubuntu-latest - env: - image: cranecloud/documentation - namespace: cranecloud-prod - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Get version - id: version - run: | - if [[ $GITHUB_EVENT_NAME == "release" ]]; then - echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT - else - echo "version=dev-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - fi - - - name: Install (Buildx) - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Login (GCP) - uses: google-github-actions/auth@v2 - with: - credentials_json: ${{ secrets.CREDENTIALS_JSON }} - - - name: Install (Gcloud) - uses: google-github-actions/setup-gcloud@v2 - with: - project_id: crane-cloud-274413 - install_components: "gke-gcloud-auth-plugin" - - - name: Get Kubernetes credentials - run: | - gcloud container clusters get-credentials staging-cluster --zone us-central1-a - - - id: meta - name: Tag - uses: docker/metadata-action@v3 - with: - flavor: | - latest=auto - prefix= - images: ${{ env.image }} - tags: | - type=ref,event=branch - type=ref,event=pr - type=sha - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Build - uses: docker/build-push-action@v5 - with: - cache-from: type=gha - cache-to: type=gha,mode=max - context: . - file: Dockerfile - labels: ${{ steps.meta.outputs.labels }} - push: true - tags: ${{ steps.meta.outputs.tags }} - - - id: export - name: Export - uses: actions/github-script@v7 - with: - script: | - const metadata = JSON.parse(`${{ steps.meta.outputs.json }}`) - const fullUrl = metadata.tags.find((t) => t.includes(':sha-')) - if (fullUrl == null) { - core.error('Unable to find sha tag of image') - } else { - const tag = fullUrl.split(':')[1] - core.setOutput('image', fullUrl) - core.setOutput('tag', tag) - } - - - name: Update deployment image - run: | - kubectl set image deployment/cranecloud-docs cranecloud-docs=${{ env.image }}:${{ steps.export.outputs.tag }} -n $namespace - - - name: Verify deployment - run: | - echo "Waiting for deployment to roll out..." - kubectl rollout status deployment/cranecloud-docs -n $namespace --timeout=300s - - echo "Verifying deployment health..." - kubectl get pods -n $namespace -l app=cranecloud-docs -o wide - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + build_and_deploy: + outputs: + image: ${{ steps.export.outputs.image }} + tag: ${{ steps.export.outputs.tag }} + release_version: ${{ steps.version.outputs.version }} + + runs-on: ubuntu-latest + env: + image: cranecloud/documentation + namespace: cranecloud-prod + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get version + id: version + run: | + if [[ $GITHUB_EVENT_NAME == "release" ]]; then + echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + else + echo "version=dev-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + fi + + - name: Install (Buildx) + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # --- GCP DEPLOYMENT --- + # - name: Login (GCP) + # uses: google-github-actions/auth@v2 + # with: + # credentials_json: ${{ secrets.CREDENTIALS_JSON }} + + # - name: Install (Gcloud) + # uses: google-github-actions/setup-gcloud@v2 + # with: + # project_id: crane-cloud-274413 + # install_components: "gke-gcloud-auth-plugin" + + # - name: Get Kubernetes credentials + # run: | + # gcloud container clusters get-credentials staging-cluster --zone us-central1-a + + # --- RENU DEPLOYMENT --- + - uses: azure/k8s-set-context@v1 + with: + kubeconfig: ${{ secrets.RENU_KUBECONFIG }} + + - id: meta + name: Tag + uses: docker/metadata-action@v3 + with: + flavor: | + latest=auto + prefix= + images: ${{ env.image }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=sha + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Build + uses: docker/build-push-action@v5 + with: + cache-from: type=gha + cache-to: type=gha,mode=max + context: . + file: Dockerfile + labels: ${{ steps.meta.outputs.labels }} + push: true + tags: ${{ steps.meta.outputs.tags }} + + - id: export + name: Export + uses: actions/github-script@v7 + with: + script: | + const metadata = JSON.parse(`${{ steps.meta.outputs.json }}`) + const fullUrl = metadata.tags.find((t) => t.includes(':sha-')) + if (fullUrl == null) { + core.setFailed(`Unable to find sha tag. Available tags: ${metadata.tags.join(', ')}`) + } else { + const tag = fullUrl.split(':')[1] + core.setOutput('image', fullUrl) + core.setOutput('tag', tag) + } + + - name: Update deployment image + run: | + kubectl set image deployment/cranecloud-docs \ + cranecloud-docs=${{ env.image }}:${{ steps.export.outputs.tag }} \ + -n $namespace + + - name: Monitor Rollout + run: | + kubectl rollout status deployment/cranecloud-docs --timeout=300s --namespace $namespace diff --git a/scripts/deployment.yml b/scripts/deployment.yml new file mode 100644 index 0000000..30cacf0 --- /dev/null +++ b/scripts/deployment.yml @@ -0,0 +1,48 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cranecloud-docs + namespace: cranecloud-prod + labels: + app: cranecloud-docs +spec: + replicas: 1 + minReadySeconds: 15 + revisionHistoryLimit: 3 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 1 + selector: + matchLabels: + app: cranecloud-docs + template: + metadata: + labels: + app: cranecloud-docs + spec: + containers: + - name: cranecloud-docs + image: cranecloud/documentation:latest + imagePullPolicy: Always + ports: + - containerPort: 80 + name: http + +--- +apiVersion: v1 +kind: Service +metadata: + name: cranecloud-docs + namespace: cranecloud-prod + labels: + app: cranecloud-docs +spec: + type: NodePort + ports: + - port: 80 + protocol: TCP + targetPort: http + selector: + app: cranecloud-docs From 1c8818e6d0dd4825de3233806f8a0874b3955cd6 Mon Sep 17 00:00:00 2001 From: Mubangizi Allan Date: Fri, 12 Jun 2026 10:19:20 +0300 Subject: [PATCH 2/2] clean out testing data --- .github/workflows/prod.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/prod.yml b/.github/workflows/prod.yml index f6735af..dd697ce 100644 --- a/.github/workflows/prod.yml +++ b/.github/workflows/prod.yml @@ -4,7 +4,6 @@ on: push: branches: - main - - ch-update-deployment release: types: - released