From 5ad543cddc8023fb2f779678e2ae793c4b349759 Mon Sep 17 00:00:00 2001 From: jenbcomp Date: Fri, 18 Oct 2024 14:45:39 +0200 Subject: [PATCH] Update CI --- .github/workflows/deploy.yml | 24 ++++++++++++++++-------- terraform/main.tf | 2 ++ yarn.lock | 4 ++++ 3 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 yarn.lock diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e462c4b..c388c6d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -10,23 +10,29 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: 'frontend' + working-directory: "frontend" steps: - name: Checkout repository uses: actions/checkout@v4 # Task 1.1: + - name: Installation + run: yarn install + + - name: Run tests + run: yarn test deploy-infrastructure: name: Deploy infrastructure with Terraform runs-on: ubuntu-latest # Task 1.2: + needs: frontend-tests env: TF_VAR_my_name: ${{ github.head_ref }} ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }} ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }} ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }} - ARM_USE_OIDC: 'true' + ARM_USE_OIDC: "true" outputs: resource-group-name: ${{ steps.terraform-output.outputs.resource_group_name }} swa-name: ${{ steps.terraform-output.outputs.swa_name }} @@ -36,7 +42,7 @@ jobs: environment: prod defaults: run: - working-directory: 'terraform' + working-directory: "terraform" steps: - name: Checkout repository uses: actions/checkout@v4 @@ -54,6 +60,8 @@ jobs: run: terraform plan # Task 2.3: + - name: Apply Infrastructure + run: terraform apply -auto-approve - name: Get Terraform output id: terraform-output @@ -85,7 +93,7 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v4 with: - node-version: '20.x' + node-version: "20.x" - name: Authenticate with Azure uses: azure/login@v2 @@ -109,7 +117,7 @@ jobs: with: azure_static_web_apps_api_token: ${{ steps.get-api-key.outputs.swa_api_key }} repo_token: ${{ github.token }} - action: 'upload' - api_location: '' - app_location: 'frontend' - output_location: 'dist' + action: "upload" + api_location: "" + app_location: "frontend" + output_location: "dist" diff --git a/terraform/main.tf b/terraform/main.tf index 71ba965..f7f6e9f 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -10,6 +10,8 @@ resource "azurerm_resource_group" "devops" { resource "azurerm_static_web_app" "devops" { name = "${var.my_name}-webapp" # Task 2.2: + resource_group_name = azurerm_resource_group.devops.name + location = local.location } output "resource_group_name" { diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +