deploy: centralize kubectl apply retry helpers #1
Workflow file for this run
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: Deploy Propositions Stack | |
| on: | |
| push: | |
| tags: | |
| - 'propositions-v*' | |
| concurrency: | |
| group: deploy-propositions-prod | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| env: | |
| GITHUB_ACTIONS: true | |
| KUBE_SERVER: ${{ secrets.KUBE_SERVER }} | |
| KUBE_CA: ${{ secrets.KUBE_CA }} | |
| KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }} | |
| GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }} | |
| GHCR_TOKEN: ${{ secrets.GHCR_TOKEN }} | |
| POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | |
| MINIO_ROOT_PASSWORD: ${{ secrets.MINIO_ROOT_PASSWORD }} | |
| APPLICATIONINSIGHTS_CONNECTION_STRING: ${{ secrets.APPLICATIONINSIGHTS_CONNECTION_STRING }} | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: propositions-prod | |
| env: | |
| K8S_IMAGE_TAG: ${{ github.ref_name }} | |
| KUBE_CONTEXT: github-context | |
| Jwt__Key: ${{ secrets.Jwt__Key }} | |
| Authentication__Google__ClientId: ${{ secrets.Authentication__Google__ClientId }} | |
| Authentication__Google__ClientSecret: ${{ secrets.Authentication__Google__ClientSecret }} | |
| ExternalApis__OpenAI__Key: ${{ secrets.ExternalApis__OpenAI__Key }} | |
| ExternalApis__TextToSpeech__Key: ${{ secrets.ExternalApis__TextToSpeech__Key }} | |
| ExternalApis__News__Key: ${{ secrets.ExternalApis__News__Key }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_API_TOKEN_CACHE: ${{ secrets.CLOUDFLARE_API_TOKEN_CACHE }} | |
| Propositions__DailyRequestsLimit: ${{ vars.Propositions__DailyRequestsLimit }} | |
| Propositions__LimitPerTopic: ${{ vars.Propositions__LimitPerTopic }} | |
| Propositions__NewsRequestLimit: ${{ vars.Propositions__NewsRequestLimit }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Validate required secrets and variables | |
| run: | | |
| bash ./src/host/WriteFluency.AppHost/validate-required-env.sh \ | |
| KUBE_SERVER \ | |
| KUBE_CA \ | |
| KUBE_TOKEN \ | |
| GHCR_USERNAME \ | |
| GHCR_TOKEN \ | |
| POSTGRES_PASSWORD \ | |
| MINIO_ROOT_PASSWORD \ | |
| APPLICATIONINSIGHTS_CONNECTION_STRING \ | |
| ExternalApis__OpenAI__Key \ | |
| ExternalApis__TextToSpeech__Key \ | |
| ExternalApis__News__Key \ | |
| CLOUDFLARE_API_TOKEN \ | |
| Propositions__DailyRequestsLimit \ | |
| Propositions__LimitPerTopic \ | |
| Propositions__NewsRequestLimit | |
| - name: Install .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Run .NET Tests | |
| run: dotnet test | |
| - name: Install Aspirate | |
| run: dotnet tool install --global aspirate --version 9.1.0 | |
| - name: Add .dotnet tools to PATH | |
| run: echo "$HOME/.dotnet/tools" >> $GITHUB_PATH | |
| - name: Configure kubeconfig using Service Account | |
| run: | | |
| mkdir -p ~/.kube | |
| cat <<EOF2 > ~/.kube/config | |
| apiVersion: v1 | |
| kind: Config | |
| clusters: | |
| - cluster: | |
| server: $KUBE_SERVER | |
| certificate-authority-data: $KUBE_CA | |
| name: cluster | |
| contexts: | |
| - context: | |
| cluster: cluster | |
| user: github | |
| name: github-context | |
| current-context: github-context | |
| users: | |
| - name: github | |
| user: | |
| token: $KUBE_TOKEN | |
| EOF2 | |
| - name: Turn scripts executable | |
| run: | | |
| chmod +x ./src/host/WriteFluency.AppHost/build-k8s-images.sh | |
| chmod +x ./src/host/WriteFluency.AppHost/deploy-k8s.sh | |
| chmod +x ./src/host/WriteFluency.AppHost/generate-k8s-secret.sh | |
| - name: Login to GitHub Container Registry (GHCR) | |
| run: echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin | |
| - name: Build propositions images | |
| working-directory: ./src/host/WriteFluency.AppHost | |
| run: ./build-k8s-images.sh propositions $K8S_IMAGE_TAG | |
| - name: Deploy propositions stack | |
| working-directory: ./src/host/WriteFluency.AppHost | |
| run: ./deploy-k8s.sh propositions $KUBE_CONTEXT |