blob: e6fbbda99f2d56f06fea294908aa719f5c44faec [file] [log] [blame]
Eric Balle8e6fa22026-06-27 16:57:30 -07001---
2# SPDX-License-Identifier: Apache-2.0
3# SPDX-FileCopyrightText: 2026 The Linux Foundation
4name: Gerrit Comment Handler
5
6# yamllint disable-line rule:truthy
7on:
8 workflow_dispatch:
9 inputs:
10 GERRIT_BRANCH:
11 description: "Branch that change is against"
12 required: true
13 type: string
14 GERRIT_CHANGE_ID:
15 description: "The ID for the change"
16 required: true
17 type: string
18 GERRIT_CHANGE_NUMBER:
19 description: "The Gerrit number"
20 required: true
21 type: string
22 GERRIT_CHANGE_URL:
23 description: "URL to the change"
24 required: true
25 type: string
26 GERRIT_EVENT_TYPE:
27 description: "Gerrit event type"
28 required: true
29 type: string
30 GERRIT_PATCHSET_NUMBER:
31 description: "The patch number for the change"
32 required: true
33 type: string
34 GERRIT_PATCHSET_REVISION:
35 description: "The revision sha"
36 required: true
37 type: string
38 GERRIT_PROJECT:
39 description: "Project in Gerrit"
40 required: true
41 type: string
42 GERRIT_REFSPEC:
43 description: "Gerrit refspec of change"
44 required: true
45 type: string
46 GERRIT_COMMENT:
47 description: "The full gha-run command line from the Gerrit comment"
48 required: true
49 type: string
50
51concurrency:
52 group: ${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
53 cancel-in-progress: true
54
55jobs:
56 # ==========================================================================
57 # JOB 1: parse-command
58 # ==========================================================================
59 # Parse GERRIT_COMMENT into a job name and parameters.
60 # ==========================================================================
61 parse-command:
62 runs-on: ubuntu-latest
63 outputs:
64 job-name: ${{ steps.parse.outputs.job-name }}
65 params: ${{ steps.parse.outputs.params }}
66 steps:
67 - name: Parse gha-run command
68 id: parse
69 env:
70 GERRIT_COMMENT: ${{ inputs.GERRIT_COMMENT }}
71 run: |
72 # Strip the leading "gha-run" verb.
73 command="${GERRIT_COMMENT#gha-run }"
74 # The first remaining token is the job name.
75 job_name="${command%% *}"
76 # Everything after the job name is the parameter string.
77 params="${command#"${job_name}"}"
78 params="${params# }"
79 echo "job-name=${job_name}" >> "${GITHUB_OUTPUT}"
80 echo "params=${params}" >> "${GITHUB_OUTPUT}"
81 echo "Parsed job name: ${job_name}"
82 echo "Parsed parameters: ${params}"
83
84 # ==========================================================================
85 # JOB 2: run-job (Route and Execute)
86 # ==========================================================================
87 # Use the parsed job name to decide what to do. A case statement keeps the
88 # routing explicit and rejects unknown job names.
89 # ==========================================================================
90 run-job:
91 needs: parse-command
92 if: ${{ needs.parse-command.outputs.job-name == 'sanity-test' }}
93 uses: opencord/shared-workflows/.github/workflows/sanity-test.yaml@main
94 secrets: inherit
95 with:
96 GERRIT_URL: ${{ inputs.GERRIT_URL }}
97 GERRIT_REFSPEC: ${{ inputs.GERRIT_REFSPEC }}
98 GERRIT_PROJECT: ${{ inputs.GERRIT_PROJECT }}
99 EXTRA_HELM_FLAGS: "--set global.image_tag=master --set onos-classic.image.tag=master"
100
101 # ==========================================================================
102 # JOB 3: report-status (Comment-Only Result Notification)
103 # ==========================================================================
104 # Report the outcome back to the Gerrit change as a comment. Use comment-only
105 # mode so the handler never casts a Verified vote on demand.
106 # ==========================================================================
107 report-status:
108 if: ${{ always() }}
109 needs: [parse-command, run-job]
110 runs-on: ubuntu-latest
111 steps:
112 - name: Get workflow conclusion
113 # yamllint disable-line rule:line-length
114 uses: im-open/workflow-conclusion@fce18569e28a9f2ed1feca1e6d4251e6a7365fdc # v2.2.4
115 - name: Report workflow conclusion
116 # yamllint disable-line rule:line-length
117 uses: lfreleng-actions/gerrit-review-action@c9df844dc6efe28b85b297c1c6d40390bfa4a378 # v1.0.0
118 with:
119 host: ${{ vars.GERRIT_SERVER }}
120 username: ${{ vars.GERRIT_SSH_USER }}
121 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
122 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
123 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
124 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
125 vote-type: ${{ env.WORKFLOW_CONCLUSION }}
126 comment-only: "true"