add telemetry collection #4
This file contains 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: Update datastore infrastucture | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'deployement/datastore-deployment/*' | |
env: | |
ARM_USE_MSI: true | |
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
ORG_NAME: ${{ secrets.ORG_NAME }} | |
REPO_NAME: ${{ secrets.REPO_NAME }} | |
jobs: | |
build-and-deploy-datastore: | |
runs-on: self-hosted | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Terraform | |
id: terraform | |
working-directory: deployement/datastore-deployment | |
run: | | |
terraform init | |
terraform plan -out datastore.tfplan | |
terraform apply datastore.tfplan | |
declare -A keys | |
keys["MONGODB_URI"]=$(terraform output -raw cosmos_connection_string) | |
keys["POSTGRESQL_FQDN"]=$(terraform output -raw posgresql_fqdn) | |
keys["POSTGRESQL_ROOT_USERNAME"]=$(terraform output -raw posgresql_admin_username) | |
keys["POSTGRESQL_ROOT_PASSWORD"]=$(terraform output -raw posgresql_admin_password) | |
# keys["REGISTRY_PASSWORD"]=$(terraform output -raw acr_token) | |
keys["REGISTRY_USERNAME"]=$(terraform output -raw acr_token_name) | |
keys["REGISTRY"]=$(terraform output -raw acr_server_name) | |
keys["REGISTRY_ID"]=$(terraform output -raw acr_id) | |
cd .. | |
public_key_info=$(curl -H "Authorization: token $ACCESS_TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$ORG_NAME/$REPO_NAME/actions/secrets/public-key) | |
public_key_value=$(echo "$public_key_info" | jq -r '.key') | |
public_key_id=$(echo "$public_key_info" | jq -r '.key_id') | |
for credential in "${!keys[@]}"; do | |
keys[$credential]=$(python3 encrypt-secret.py ${keys[$credential]} $public_key_value) | |
echo '{"encrypted_value":"'${keys[$credential]}'","key_id":"'$public_key_id'"}' > body.json | |
curl -L -X PUT -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $ACCESS_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/$ORG_NAME/$REPO_NAME/actions/secrets/$credential -d @body.json | |
done |