name: POC GitOps Dispatch run-name: "POC (${{ inputs.dispatch_id || 'orchestrator' }})" on: push: branches: - feature/gitops workflow_dispatch: inputs: dispatch_id: required: true type: string type: required: true type: string jobs: orchestrator: if: github.event_name == 'push' runs-on: ubuntu-latest steps: - name: Generate dispatch_id id: gen run: | ID=$(date +%s | md5sum | head -c 8) echo "dispatch_id=$ID" >> "$GITHUB_OUTPUT" - name: Dispatch test run with dispatch_id run: | INPUTS=$(jq -nc \ --arg dispatch_id "${{ steps.gen.outputs.dispatch_id }}" \ --arg type "auto" \ '{dispatch_id: $dispatch_id, type: $type}') curl -s -X POST \ "${{ gitea.server_url }}/api/v1/repos/${{ github.repository }}/actions/workflows/poc-dispatch.yml/dispatches" \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ -H "Content-Type: application/json" \ -d "$(jq -nc --arg ref "${{ github.ref_name }}" --argjson inputs "$INPUTS" '{ref: $ref, inputs: $inputs}')" - name: Poll for dispatched run run: | ID=${{ steps.gen.outputs.dispatch_id }} for i in $(seq 1 12); do RUNS=$(curl -s "${{ gitea.server_url }}/api/v1/repos/${{ github.repository }}/actions/runs?event=workflow_dispatch&limit=10" \ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}") FOUND=$(echo "$RUNS" | jq -r --arg id "$ID" \ '[.workflow_runs[] | select(.display_title | contains($id))] | .[0].id // empty') if [ -n "$FOUND" ]; then echo "POC PASS: found run id=$FOUND with display_title containing '$ID'" exit 0 fi sleep 5 done echo "POC FAIL: no run found with display_title containing '$ID'" echo "$RUNS" exit 1 test: if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - run: | echo "POC dispatch_id=${{ inputs.dispatch_id }} type=${{ inputs.type }}"