diff --git a/.github/workflows/trigger_rebuild.yaml b/.github/workflows/trigger_rebuild.yaml index cd1b69d..a80ee5f 100644 --- a/.github/workflows/trigger_rebuild.yaml +++ b/.github/workflows/trigger_rebuild.yaml @@ -1,34 +1,34 @@ -name: Trigger Build +name: Trigger Container Rebuild on: push: branches: - - main # or whichever branches you want to monitor + - main jobs: trigger: runs-on: ubuntu-latest steps: - - name: Trigger container rebuild + - name: Trigger rebuild + env: + GH_TOKEN: ${{ secrets.PUBLIC_REPO_SYNC_TOKEN }} run: | - curl -L \ - -X GET \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/Cian-H/my_nvim - + if [ -z "$GH_TOKEN" ]; then + echo "Error: PUBLIC_REPO_SYNC_TOKEN secret is not set" + exit 1 + fi + response=$(curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.PUBLIC_REPO_SYNC_TOKEN }}" \ + -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 }}"}}') - if [ "$response" -ne 200 ]; then + if [ "$response" -ne 204 ]; then echo "Failed to trigger workflow. HTTP status code: $response" exit 1 fi