From b034bb1ea4e4421f18049c231b8efbd88d3f96c8 Mon Sep 17 00:00:00 2001 From: Cian Hughes Date: Wed, 22 Jan 2025 15:50:22 +0000 Subject: [PATCH] Update trigger_rebuild.yaml --- .github/workflows/trigger_rebuild.yaml | 37 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/.github/workflows/trigger_rebuild.yaml b/.github/workflows/trigger_rebuild.yaml index aa39000..4fc0539 100644 --- a/.github/workflows/trigger_rebuild.yaml +++ b/.github/workflows/trigger_rebuild.yaml @@ -9,7 +9,7 @@ jobs: trigger: runs-on: ubuntu-latest steps: - - name: Trigger rebuild + - name: Test repository access env: GH_TOKEN: ${{ secrets.PUBLIC_ACTION_TRIGGER_TOKEN }} run: | @@ -18,19 +18,34 @@ jobs: exit 1 fi - response=$(curl -L \ - -X POST \ + # First test if we can access the repository + echo "Testing repository access..." + repo_response=$(curl -s -o /dev/null -w "%{http_code}" \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GH_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - -w "%{http_code}" \ - -o /dev/null \ - https://api.github.com/repos/Cian-H/my_nvim/dispatches \ - -d '{"event_type":"rebuild-container","client_payload":{"repository":"${{ github.repository }}"}}') + https://api.github.com/repos/Cian-H/my_nvim) + + echo "Repository access status code: $repo_response" - if [ "$response" -ne 204 ]; then - echo "Failed to trigger workflow. HTTP status code: $response" + # If we can access the repo, try to create the dispatch + if [ "$repo_response" -eq 200 ]; then + echo "Repository is accessible, attempting dispatch..." + dispatch_response=$(curl -s -o /dev/null -w "%{http_code}" \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GH_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/Cian-H/my_nvim/dispatches \ + -d '{"event_type":"rebuild-container","client_payload":{"repository":"${{ github.repository }}"}}') + + echo "Dispatch status code: $dispatch_response" + + if [ "$dispatch_response" -ne 204 ]; then + echo "Failed to create dispatch event" + exit 1 + fi + else + echo "Cannot access repository" exit 1 fi - - echo "Successfully triggered workflow"