diff --git a/.github/workflows/ansible-monitoring.yml b/.github/workflows/ansible-monitoring.yml index b287389..5477097 100644 --- a/.github/workflows/ansible-monitoring.yml +++ b/.github/workflows/ansible-monitoring.yml @@ -1,9 +1,11 @@ name: Ansible Monitoring on: - repository_dispatch: + workflow_dispatch: + workflow_run: + workflows: ["Terraform Apply"] types: - - ansible-monitoring + - completed jobs: monitoring-stack-deploy: @@ -11,11 +13,33 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + ref: infra_features + + - 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 + 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@v3 + uses: actions/download-artifact@v4 with: name: ansible_inventory + github-token: ${{ secrets.TOKEN }} + run-id: ${{ steps.get-run-id.outputs.run_id }} - name: Verify Ansible Inventory run: | diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml new file mode 100644 index 0000000..3266d2a --- /dev/null +++ b/.github/workflows/hello.yml @@ -0,0 +1,26 @@ +name: Simple Workflow + +on: + workflow_dispatch: + workflow_run: + workflows: ["Terraform Apply"] + types: + - completed + 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' + + diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index 1b7b734..0e6116f 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -41,6 +41,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + with: + ref: infra_features - name: Write Private Key to File run: | @@ -62,12 +64,11 @@ 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 - name: Upload Ansible Inventory - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ansible_inventory path: ./terraform/inventory.ini @@ -76,15 +77,15 @@ 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: | - ./public_ip_env.txt - - name: Trigger Ansible Monitoring Workflow - uses: peter-evans/repository-dispatch@v2 - with: - 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 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