From e1ec3ae3aca39e065b7ee419c8929ddd5cdf2767 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:35:36 +0100 Subject: [PATCH 01/18] modify apply yml --- .github/workflows/terraform-apply.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index 1b7b734..655cabd 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -62,7 +62,6 @@ jobs: if [ "${{ github.event.inputs.operation }}" = "destroy" ]; then terraform destroy --auto-approve else - terraform destroy --auto-approve terraform apply --auto-approve fi working-directory: ./terraform From 0757c99169d77407c7b62925257c30e602a02f99 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:43:06 +0100 Subject: [PATCH 02/18] modify workflow --- .github/workflows/terraform-apply.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index 655cabd..eeb698e 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -83,6 +83,7 @@ jobs: - name: Trigger Ansible Monitoring Workflow uses: peter-evans/repository-dispatch@v2 with: + token: ${{ secrets.TOKEN }} event-type: ansible-monitoring From 97328b84f9b8c4a939c95761f11f62d2d17fbff8 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:23:58 +0100 Subject: [PATCH 03/18] modify ansible monitoring workflow --- .github/workflows/ansible-monitoring.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index b287389..43893f8 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -16,6 +16,8 @@ jobs: uses: actions/download-artifact@v3 with: name: ansible_inventory + github-token: ${{ secrets.TOKEN }} + run-id: ${{ github.event.client_payload.run_id }} - name: Verify Ansible Inventory run: | From 55197723403da4cffc520d584a463f589f41a80f Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:28:55 +0100 Subject: [PATCH 04/18] modiy ansible workflow --- .github/workflows/ansible-monitoring.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index 43893f8..9d4e68a 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -1,6 +1,7 @@ name: Ansible Monitoring on: + workflow_dispatch: repository_dispatch: types: - ansible-monitoring @@ -12,6 +13,11 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Write Private Key to File + run: | + echo "${{ secrets.PRIVATE_KEY }}" > ${{ vars.TF_KEY_PAIR_NAME }}.pem + chmod 600 ${{ vars.TF_KEY_PAIR_NAME }}.pem + - name: Download Ansible Inventory uses: actions/download-artifact@v3 with: From d53272a84886ba2df949e8b4e5d7c45a61eff902 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:33:16 +0100 Subject: [PATCH 05/18] modify ansible workflow --- .github/workflows/ansible-monitoring.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index 9d4e68a..ab40871 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -19,7 +19,7 @@ jobs: chmod 600 ${{ vars.TF_KEY_PAIR_NAME }}.pem - name: Download Ansible Inventory - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ansible_inventory github-token: ${{ secrets.TOKEN }} From a8f94f3706cb7b4577860925376d534bf56ef177 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:47:13 +0100 Subject: [PATCH 06/18] testing ansible workflow --- .github/workflows/ansible-monitoring.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index ab40871..483f645 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -17,6 +17,7 @@ jobs: run: | echo "${{ secrets.PRIVATE_KEY }}" > ${{ vars.TF_KEY_PAIR_NAME }}.pem chmod 600 ${{ vars.TF_KEY_PAIR_NAME }}.pem + echo "${{ github.event.client_payload.run_id }}" - name: Download Ansible Inventory uses: actions/download-artifact@v4 From 616bcf50f0b4c7a228e714026acd57942c0cc786 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:48:49 +0100 Subject: [PATCH 07/18] testing ansible workflow --- .github/workflows/ansible-monitoring.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index 483f645..e007e58 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -18,6 +18,7 @@ jobs: echo "${{ secrets.PRIVATE_KEY }}" > ${{ vars.TF_KEY_PAIR_NAME }}.pem chmod 600 ${{ vars.TF_KEY_PAIR_NAME }}.pem echo "${{ github.event.client_payload.run_id }}" + echo "${{ github.event.workflow_run.id }}" - name: Download Ansible Inventory uses: actions/download-artifact@v4 From 8daeb8758b61c76160e8bacdbe1429b4691fee64 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:54:05 +0100 Subject: [PATCH 08/18] modify apply workflow --- .github/workflows/terraform-apply.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index eeb698e..bdef29b 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -66,7 +66,7 @@ jobs: fi working-directory: ./terraform - name: Upload Ansible Inventory - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ansible_inventory path: ./terraform/inventory.ini @@ -75,7 +75,7 @@ jobs: echo "public_ip=$(terraform output -raw instance_public_ip)" > public_ip_env.txt working-directory: ./terraform - name: Upload Public_IP - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Public_IP path: | From 0b15e6f3dee28423c5b9a20088db1ac5196562ee Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 16:06:34 +0100 Subject: [PATCH 09/18] update monitoring workflow --- .github/workflows/ansible-monitoring.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index e007e58..5e2db50 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -13,6 +13,17 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Get Workflow Run ID + id: get-run-id + run: | + RUN_ID=$(curl -s \ + -H "Authorization: Bearer ${{ secrets.TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/${{ github.repository }}/actions/workflows/terraform-apply.yml/runs?branch=infra_features&per_page=1" \ + | jq -r '.workflow_runs[0].id') + echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT + echo "$RUN_ID" + - name: Write Private Key to File run: | echo "${{ secrets.PRIVATE_KEY }}" > ${{ vars.TF_KEY_PAIR_NAME }}.pem @@ -25,7 +36,7 @@ jobs: with: name: ansible_inventory github-token: ${{ secrets.TOKEN }} - run-id: ${{ github.event.client_payload.run_id }} + run-id: ${{ steps.get-run-id.outputs.run_id }} - name: Verify Ansible Inventory run: | From f5850939bd3e31895fc21d7f81890cffbd6502ce Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:37:26 +0100 Subject: [PATCH 10/18] update ansible workflow --- .github/workflows/ansible-monitoring.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index 5e2db50..95e36ef 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -2,9 +2,10 @@ name: Ansible Monitoring on: workflow_dispatch: - repository_dispatch: - types: - - ansible-monitoring + workflow_run: + workflows: ["Terraform Apply"] + types: + - completed jobs: monitoring-stack-deploy: From 5903b7ebbced299bb46bd7d82c6b0bf16576fc59 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:45:48 +0100 Subject: [PATCH 11/18] update --- .github/workflows/ansible-monitoring.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index 95e36ef..acae9f0 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -1,7 +1,7 @@ name: Ansible Monitoring on: - workflow_dispatch: + # workflow_dispatch: workflow_run: workflows: ["Terraform Apply"] types: From 3c7a18e04323d6ceef66c307bbdfa100e7a23263 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:46:40 +0100 Subject: [PATCH 12/18] update --- .github/workflows/ansible-monitoring.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index acae9f0..95e36ef 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -1,7 +1,7 @@ name: Ansible Monitoring on: - # workflow_dispatch: + workflow_dispatch: workflow_run: workflows: ["Terraform Apply"] types: From b6138a4ff3ff027728fadf25cfa61edab92ed858 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:56:20 +0100 Subject: [PATCH 13/18] update --- .github/workflows/terraform-apply.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index bdef29b..18aaddf 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -2,16 +2,16 @@ name: Terraform Apply # run-name: ${{ github.actor }} triggered the pipeline on: - workflow_dispatch: - inputs: - operation: - description: 'Choose the Terraform operation' - required: true - default: 'apply' - type: choice - options: - - apply - - destroy + # workflow_dispatch: + # inputs: + # operation: + # description: 'Choose the Terraform operation' + # required: true + # default: 'apply' + # type: choice + # options: + # - apply + # - destroy push: branches: - 'infra_main' From aa03dfa3af303fa0ecc7054188c966b8282192c6 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Wed, 11 Dec 2024 23:28:11 +0100 Subject: [PATCH 14/18] add sample workflow --- .github/workflows/hello.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/hello.yml diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml new file mode 100644 index 0000000..aba302f --- /dev/null +++ b/.github/workflows/hello.yml @@ -0,0 +1,25 @@ +name: Simple Workflow + +on: + push: + branches: + - 'infra_features' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + From b4c689f1b6ba55af62600d01d95035bc573013b0 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Thu, 12 Dec 2024 00:01:31 +0100 Subject: [PATCH 15/18] test --- terraform/bkp.terraform.tfvars.k | 1 + 1 file changed, 1 insertion(+) diff --git a/terraform/bkp.terraform.tfvars.k b/terraform/bkp.terraform.tfvars.k index cd79c31..84cc9e3 100644 --- a/terraform/bkp.terraform.tfvars.k +++ b/terraform/bkp.terraform.tfvars.k @@ -11,3 +11,4 @@ traefik_domain = "traefik.cv1.drintech.online" cert_email = "admin@example.com" # replace with a valid email Let's move on +just a test \ No newline at end of file From 588d277a1018891225b8977b1562ed4d8713752e Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Thu, 12 Dec 2024 00:05:29 +0100 Subject: [PATCH 16/18] add dispatch to sample workflow --- .github/workflows/hello.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index aba302f..155821b 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -1,6 +1,7 @@ name: Simple Workflow on: + workflow_dispatch: push: branches: - 'infra_features' @@ -18,8 +19,4 @@ jobs: with: python-version: '3.8' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt From bc23120ab3570a09ac0ff9fe35c471de1c7f8419 Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Thu, 12 Dec 2024 00:15:02 +0100 Subject: [PATCH 17/18] test sample wf --- .github/workflows/hello.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 155821b..1d39b31 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -2,6 +2,7 @@ name: Simple Workflow on: workflow_dispatch: + workflow_run: push: branches: - 'infra_features' From f1d5a4733b8a4fa84318caabfcf6cefd0e3d911a Mon Sep 17 00:00:00 2001 From: Okesanya Odunayo <94924061+DrInTech22@users.noreply.github.com> Date: Thu, 12 Dec 2024 00:35:27 +0100 Subject: [PATCH 18/18] testing workflows --- .github/workflows/ansible-monitoring.yml | 8 ++++-- .github/workflows/hello.yml | 3 ++ .github/workflows/terraform-apply.yml | 35 ++++++++++++------------ 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index 95e36ef..5477097 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -3,9 +3,9 @@ name: Ansible Monitoring on: workflow_dispatch: workflow_run: - workflows: ["Terraform Apply"] - types: - - completed + workflows: ["Terraform Apply"] + types: + - completed jobs: monitoring-stack-deploy: @@ -13,6 +13,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + ref: infra_features - name: Get Workflow Run ID id: get-run-id diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml index 1d39b31..3266d2a 100644 --- a/.github/workflows/hello.yml +++ b/.github/workflows/hello.yml @@ -3,6 +3,9 @@ name: Simple Workflow on: workflow_dispatch: workflow_run: + workflows: ["Terraform Apply"] + types: + - completed push: branches: - 'infra_features' diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index 18aaddf..0e6116f 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -2,16 +2,16 @@ name: Terraform Apply # run-name: ${{ github.actor }} triggered the pipeline on: - # workflow_dispatch: - # inputs: - # operation: - # description: 'Choose the Terraform operation' - # required: true - # default: 'apply' - # type: choice - # options: - # - apply - # - destroy + workflow_dispatch: + inputs: + operation: + description: 'Choose the Terraform operation' + required: true + default: 'apply' + type: choice + options: + - apply + - destroy push: branches: - 'infra_main' @@ -41,6 +41,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + ref: infra_features - name: Write Private Key to File run: | @@ -78,13 +80,12 @@ jobs: uses: actions/upload-artifact@v4 with: name: Public_IP - path: | - ./public_ip_env.txt - - name: Trigger Ansible Monitoring Workflow - uses: peter-evans/repository-dispatch@v2 - with: - token: ${{ secrets.TOKEN }} - event-type: ansible-monitoring + path: ./public_ip_env.txt + # - name: Trigger Ansible Monitoring Workflow + # uses: peter-evans/repository-dispatch@v2 + # with: + # token: ${{ secrets.TOKEN }} + # event-type: ansible-monitoring