Skip to content

Build & Deploy

Build & Deploy #132

Workflow file for this run

name: Build & Deploy
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: '10 0 * * 0'
permissions:
id-token: write
contents: read
packages: write
jobs:
package:
uses: Chia-Network/actions/.github/workflows/docker-build.yaml@main
deploy_internal:
name: Deploy Internal - ${{ matrix.colo.region }}
needs:
- package
runs-on: "k8s-public-${{ matrix.colo.region }}"
container:
image: registry.gitlab.com/cmmarslender/kubectl-helm:v3
strategy:
fail-fast: false
matrix:
colo:
- region: fmt
- region: msp
- region: ldn
- region: sin
steps:
- uses: actions/checkout@v4
- name: Vault Login
uses: Chia-Network/actions/vault/login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
role_name: github-block-metrics
- name: Get secrets from vault
uses: hashicorp/vault-action@v3
with:
url: ${{ secrets.VAULT_URL }}
token: ${{ env.VAULT_TOKEN }}
secrets: |
secret/data/${{ matrix.colo.region }}/mysql/db-info host | DB_HOST;
secret/data/${{ matrix.colo.region }}/mysql/users/block-metrics username | DB_USER;
secret/data/${{ matrix.colo.region }}/mysql/users/block-metrics password | DB_PASSWORD;
secret/data/github/ghcr_image_pull username | IMAGE_PULL_USERNAME;
secret/data/github/ghcr_image_pull password | IMAGE_PULL_PASSWORD;
secret/data/${{ matrix.colo.region }}/k8s/k8s-${{ matrix.colo.region }} api_server_url | K8S_API_SERVER_URL;
secret/data/${{ matrix.colo.region }}/k8s/k8s-${{ matrix.colo.region }} private_crt | PRIVATE_CRT;
secret/data/${{ matrix.colo.region }}/k8s/k8s-${{ matrix.colo.region }} private_key | PRIVATE_KEY;
secret/data/${{ matrix.colo.region }}/k8s/k8s-${{ matrix.colo.region }} public_crt | PUBLIC_CRT;
secret/data/${{ matrix.colo.region }}/k8s/k8s-${{ matrix.colo.region }} public_key | PUBLIC_KEY;
- name: Get config.yaml
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "CONFIG_YAML<<$EOF" >> $GITHUB_ENV
cat k8s/config.yaml >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Login to k8s cluster
uses: Chia-Network/actions/vault/k8s-login@main
with:
vault_url: ${{ secrets.VAULT_URL }}
vault_token: ${{ env.VAULT_TOKEN }}
backend_name: k8s-${{ matrix.colo.region }}
role_name: github-actions
cluster_url: ${{ env.K8S_API_SERVER_URL }}
- uses: Chia-Network/actions/k8s/image-pull-secret@main
with:
secret_name: block-metrics-image-pull
namespace: block-metrics
username: ${{ env.IMAGE_PULL_USERNAME }}
password: ${{ env.IMAGE_PULL_PASSWORD }}
docker_server: "ghcr.io"
- name: Configure namespace for istio
run: kubectl label namespace block-metrics istio-injection=enabled
- uses: Chia-Network/actions/helm/deploy@main
env:
DOCKER_TAG: "sha-${{ github.sha }}"
with:
namespace: "block-metrics"
app_name: "block-metrics"
helm_chart_repo: "https://chia-network.github.io/helm-charts"
helm_chart: "generic"
helm_values: "./k8s/internal.yaml"