From 6f4e2290ed3317ea5bc5a92fa250b58090a86343 Mon Sep 17 00:00:00 2001 From: Anais Date: Sat, 20 Jan 2024 17:41:29 +0100 Subject: [PATCH] datastore iac completed --- .github/workflows/infrastructure.yml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/infrastructure.yml b/.github/workflows/infrastructure.yml index 7dbd33c..5edc786 100644 --- a/.github/workflows/infrastructure.yml +++ b/.github/workflows/infrastructure.yml @@ -25,22 +25,17 @@ jobs: terraform init terraform plan -out datastore.tfplan terraform apply datastore.tfplan - echo "MONGODB_URI=$(terraform output -raw cosmos_connection_string)" >> "$GITHUB_OUTPUT" - echo "POSTGRESQL_FQDN=$(terraform output -raw posgresql_fqdn)" >> "$GITHUB_OUTPUT" - echo "POSTGRESQL_ROOT_USERNAME=$(terraform output -raw posgresql_admin_username)" >> "$GITHUB_OUTPUT" - echo "POSTGRESQL_ROOT_PASSWORD=$(terraform output -raw posgresql_admin_password)" >> "$GITHUB_OUTPUT" - echo "REGISTRY_PASSWORD=$(terraform output -raw acr_token)" >> "$GITHUB_OUTPUT" - echo "REGISTRY_USERNAME=$(terraform output -raw acr_token_name)" >> "$GITHUB_OUTPUT" - echo "REGISTRY=$(terraform output -raw acr_server_name)" >> "$GITHUB_OUTPUT" - echo "REGISTRY_ID=$(terraform output -raw acr_id)" >> "$GITHUB_OUTPUT" - - - name: Update Github actions secrets - working-directory: deployement - run: | declare -A keys - keys["POSTGRESQL_FQDN"]=${{ steps.terraform.outputs.POSTGRESQL_FQDN }} - keys["REGISTRY"]=${{ steps.terraform.outputs.REGISTRY }} + 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') @@ -49,6 +44,3 @@ jobs: 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 - - test=${{ secrets.REGISTRY }} - echo $test \ No newline at end of file