|
| 1 | +--- |
| 2 | +apiVersion: tekton.dev/v1beta1 |
| 3 | +kind: PipelineRun |
| 4 | +metadata: |
| 5 | + name: start-gha-workflow |
| 6 | + annotations: |
| 7 | + pipelinesascode.tekton.dev/max-keep-runs: "2" |
| 8 | + pipelinesascode.tekton.dev/cancel-in-progress: "true" |
| 9 | + pipelinesascode.tekton.dev/on-event: "pull_request" |
| 10 | + pipelinesascode.tekton.dev/on-target-branch: "main" |
| 11 | + pipelinesascode.tekton.dev/on-path-change: "[***/*.go, .github/workflows/*l]" |
| 12 | +spec: |
| 13 | + params: |
| 14 | + - name: repo_url |
| 15 | + value: "{{repo_url}}" |
| 16 | + - name: revision |
| 17 | + value: "{{revision}}" |
| 18 | + pipelineSpec: |
| 19 | + params: |
| 20 | + - name: repo_url |
| 21 | + - name: revision |
| 22 | + tasks: |
| 23 | + - name: trigger-workflow |
| 24 | + taskSpec: |
| 25 | + workspaces: |
| 26 | + - name: source |
| 27 | + steps: |
| 28 | + - name: fetch-repo |
| 29 | + ref: |
| 30 | + resolver: http |
| 31 | + params: |
| 32 | + - name: url |
| 33 | + value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml |
| 34 | + params: |
| 35 | + - name: output-path |
| 36 | + value: $(workspaces.source.path) |
| 37 | + - name: url |
| 38 | + value: "$(params.repo_url)" |
| 39 | + - name: revision |
| 40 | + value: "$(params.revision)" |
| 41 | + - name: dispatch-workflow |
| 42 | + # it has curl and we already pulled it |
| 43 | + image: registry.access.redhat.com/ubi9/ubi |
| 44 | + workingDir: $(workspaces.source.path) |
| 45 | + env: |
| 46 | + - name: HUB_TOKEN |
| 47 | + valueFrom: |
| 48 | + secretKeyRef: |
| 49 | + name: "nightly-ci-github-hub-token" |
| 50 | + key: "hub-token" |
| 51 | + script: | |
| 52 | + #!/usr/bin/env bash |
| 53 | + set -eux |
| 54 | + WORKFLOW=nightly_push_dispatch.yaml |
| 55 | + REPO="" |
| 56 | +
|
| 57 | + url=$(curl -s -f -X GET -H "Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview" \ |
| 58 | + -H "Authorization: token ${HUB_TOKEN}" \ |
| 59 | + -H "User-Agent: PAC" \ |
| 60 | + https://api.github.com/repos/{{ repo_owner }}/{{ repo_name }}/actions/workflows/.github%2Fworkflows%2F${WORKFLOW} | |
| 61 | + sed -n 's/.*"url":"\([^"]*\)".*/\1/p') |
| 62 | + [[ -z $url ]] && { echo "No url found" && exit 1; } |
| 63 | +
|
| 64 | + curl -s -f -X POST -H "Accept: application/vnd.github.v3+json" \ |
| 65 | + -H "Authorization: token ${HUB_TOKEN}" \ |
| 66 | + -H "Content-Type: application/json" \ |
| 67 | + -d '{"ref":"main", "inputs": {"sha": "{{ revision }}"}}' \ |
| 68 | + ${url}/dispatches |
| 69 | +
|
| 70 | + workspaces: |
| 71 | + - name: source |
| 72 | + workspace: source |
| 73 | + workspaces: |
| 74 | + - name: source |
| 75 | + workspaces: |
| 76 | + - name: source |
| 77 | + emptyDir: {} |
0 commit comments