From 4461720fb60008bd60a747876788c4d14e563916 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:13:05 +0500 Subject: [PATCH 01/15] Create trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/trigger_local_env.yml diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml new file mode 100644 index 0000000..d57fa8a --- /dev/null +++ b/.github/workflows/trigger_local_env.yml @@ -0,0 +1,20 @@ +name: Trigger Local Env + +on: + push: + branches: + - master + +jobs: + trigger: + runs-on: ubuntu-latest + steps: + - name: Send dispatch event + env: + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + run: | + curl -X POST \ + -H "Accept: application/vnd.github.everest-preview+json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + https://api.github.com/repos/Yam1x/to-dos-local-env/dispatches \ + -d '{"event_type": "trigger_from_API"}' From 0eb306b13a712b2bd5738aae8a184b64d91d32de Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:13:38 +0500 Subject: [PATCH 02/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index d57fa8a..7820d50 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -17,4 +17,4 @@ jobs: -H "Accept: application/vnd.github.everest-preview+json" \ -H "Authorization: token $GITHUB_TOKEN" \ https://api.github.com/repos/Yam1x/to-dos-local-env/dispatches \ - -d '{"event_type": "trigger_from_API"}' + -d '{"event_type": "trigger_from_API"}' From b8b2ac56c175ec98517beb9589a203dfe68b0bf2 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:39:42 +0500 Subject: [PATCH 03/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 7820d50..c10653a 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -18,3 +18,30 @@ jobs: -H "Authorization: token $GITHUB_TOKEN" \ https://api.github.com/repos/Yam1x/to-dos-local-env/dispatches \ -d '{"event_type": "trigger_from_API"}' + + - name: Wait for Local Env tests to pass + run: | + sleep 20 + + while true; do + STATUS=$(curl -s -H "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \ + https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs \ + | jq '.workflow_runs | map(select(.event == "repository_dispatch" and .display_title == "trigger_from_API")) | .[0].status') + + if [ "$STATUS" == "\"completed\"" ]; then + CONCLUSION=$(curl -s -H "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \ + https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs \ + | jq '.workflow_runs | map(select(.event == "repository_dispatch" and .display_title == "trigger_from_API")) | .[0].conclusion') + + if [ "$CONCLUSION" == "\"success\"" ]; then + echo "Tests passed" + exit 0 + else + echo "Tests failed" + exit 1 + fi + else + echo "Waiting for test results..." + sleep 30 + fi + done From c6cda9f01dff8b5ca1019b23ee0062b623e46c2e Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:40:27 +0500 Subject: [PATCH 04/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index c10653a..0b2ae32 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -3,7 +3,7 @@ name: Trigger Local Env on: push: branches: - - master + - test jobs: trigger: From e2dc0838b06452fe6c61b4072969afb94a5108c1 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:49:13 +0500 Subject: [PATCH 05/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 0b2ae32..548eda1 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -1,9 +1,10 @@ name: Trigger Local Env on: - push: + pull_request: branches: - test + types: [opened, synchronize, reopened] jobs: trigger: From be89dbf3822a703f6838835fb7ec9dd74035bd50 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:29:03 +0500 Subject: [PATCH 06/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 548eda1..73d6e0e 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -14,11 +14,12 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} run: | + echo "${{ github.head_ref }}" curl -X POST \ -H "Accept: application/vnd.github.everest-preview+json" \ -H "Authorization: token $GITHUB_TOKEN" \ https://api.github.com/repos/Yam1x/to-dos-local-env/dispatches \ - -d '{"event_type": "trigger_from_API"}' + -d '{"event_type": "trigger_from_API", "client_payload": {"branch": "${{ github.head_ref }}"}}' - name: Wait for Local Env tests to pass run: | From b7f00ae6b4e36d6c1d192e5f73d39c8665e35b48 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:57:42 +0500 Subject: [PATCH 07/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 73d6e0e..d1b7b6a 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -19,7 +19,7 @@ jobs: -H "Accept: application/vnd.github.everest-preview+json" \ -H "Authorization: token $GITHUB_TOKEN" \ https://api.github.com/repos/Yam1x/to-dos-local-env/dispatches \ - -d '{"event_type": "trigger_from_API", "client_payload": {"branch": "${{ github.head_ref }}"}}' + -d '{"event_type": "trigger_from_API", "client_payload": {"branch": "${{ github.head_ref }}"}}' - name: Wait for Local Env tests to pass run: | From 8578009112dd4068cd8c15abf832544797fc20dd Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:58:43 +0500 Subject: [PATCH 08/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index d1b7b6a..6fe22da 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -3,7 +3,7 @@ name: Trigger Local Env on: pull_request: branches: - - test + - main types: [opened, synchronize, reopened] jobs: From fa118c54ad0d10e3bf6482a30e82ca476f7f2849 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:58:55 +0500 Subject: [PATCH 09/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 6fe22da..3992168 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -3,7 +3,7 @@ name: Trigger Local Env on: pull_request: branches: - - main + - master types: [opened, synchronize, reopened] jobs: From c8baa5901d279b313fd47e88833613170cf54e09 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:59:27 +0500 Subject: [PATCH 10/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 3992168..b87648d 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -19,7 +19,7 @@ jobs: -H "Accept: application/vnd.github.everest-preview+json" \ -H "Authorization: token $GITHUB_TOKEN" \ https://api.github.com/repos/Yam1x/to-dos-local-env/dispatches \ - -d '{"event_type": "trigger_from_API", "client_payload": {"branch": "${{ github.head_ref }}"}}' + -d '{"event_type": "trigger_from_API", "client_payload": {"branch": "${{ github.head_ref }}"}}' - name: Wait for Local Env tests to pass run: | From a19962125f8862dbadf32696b062a7f922f1cd99 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 5 Dec 2024 20:55:48 +0500 Subject: [PATCH 11/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 28 +++++++++++++++---------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index b87648d..4824c15 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -23,23 +23,29 @@ jobs: - name: Wait for Local Env tests to pass run: | - sleep 20 - + sleep 10 + + RUN_ID=$(curl -s -H "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \ + "https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs?event=repository_dispatch" \ + | jq -r '.workflow_runs | map(select(.display_title == "trigger_from_API")) | .[0].id') + + echo "Workflow Run ID: $RUN_ID" + while true; do STATUS=$(curl -s -H "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \ - https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs \ - | jq '.workflow_runs | map(select(.event == "repository_dispatch" and .display_title == "trigger_from_API")) | .[0].status') - - if [ "$STATUS" == "\"completed\"" ]; then + "https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs/$RUN_ID" \ + | jq -r '.status') + + if [ "$STATUS" == "completed" ]; then CONCLUSION=$(curl -s -H "Authorization: token ${{ secrets.DISPATCH_TOKEN }}" \ - https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs \ - | jq '.workflow_runs | map(select(.event == "repository_dispatch" and .display_title == "trigger_from_API")) | .[0].conclusion') - - if [ "$CONCLUSION" == "\"success\"" ]; then + "https://api.github.com/repos/Yam1x/to-dos-local-env/actions/runs/$RUN_ID" \ + | jq -r '.conclusion') + + if [ "$CONCLUSION" == "success" ]; then echo "Tests passed" exit 0 else - echo "Tests failed" + echo "Tests failed" exit 1 fi else From e83e48c3dfe545223c6cd8377920b19b6d8917e2 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:15:30 +0500 Subject: [PATCH 12/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 4824c15..5b08bf7 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - master - types: [opened, synchronize, reopened] jobs: trigger: From 097fd4e68910de2c60ed3f8f70bcf55b3945e6d4 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:59:08 +0500 Subject: [PATCH 13/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 5b08bf7..2b6fa85 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -8,7 +8,7 @@ on: jobs: trigger: runs-on: ubuntu-latest - steps: + steps: - name: Send dispatch event env: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} From 4b29119d39761f55947071cba68372767ef9b472 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:12:48 +0500 Subject: [PATCH 14/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 2b6fa85..0009fec 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -52,3 +52,4 @@ jobs: sleep 30 fi done + From 390f011ad3642563900972f3654718a3d2418124 Mon Sep 17 00:00:00 2001 From: Maxim <81160491+Yam1x@users.noreply.github.com> Date: Thu, 19 Dec 2024 05:04:03 +0500 Subject: [PATCH 15/15] Update trigger_local_env.yml --- .github/workflows/trigger_local_env.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger_local_env.yml b/.github/workflows/trigger_local_env.yml index 0009fec..e051f63 100644 --- a/.github/workflows/trigger_local_env.yml +++ b/.github/workflows/trigger_local_env.yml @@ -11,7 +11,7 @@ jobs: steps: - name: Send dispatch event env: - GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} + GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} run: | echo "${{ github.head_ref }}" curl -X POST \