Update trigger_rebuild.yaml

This commit is contained in:
2025-01-22 15:50:22 +00:00
committed by GitHub
parent 682a39696e
commit b034bb1ea4

View File

@@ -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)
if [ "$response" -ne 204 ]; then
echo "Failed to trigger workflow. HTTP status code: $response"
echo "Repository access status code: $repo_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"