-
Notifications
You must be signed in to change notification settings - Fork 13
90 lines (85 loc) · 3.61 KB
/
trigger-testing.yaml
File metadata and controls
90 lines (85 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
name: Trigger Testing
run-name: Dispatch operator PR test for ${{ github.event.issue.number || github.event.inputs.pr_number }}
on:
issue_comment:
types: [created]
workflow_dispatch:
inputs:
pr_number:
description: "PR number to test"
required: true
type: string
platform:
description: "Platform to test on (e.g. k3s-amd, eks-amd)"
required: true
type: string
jobs:
dispatch:
name: Dispatch operator-pr-test
runs-on: ubuntu-22.04
# Run on /testing comments from authorized users, or on manual dispatch
if: >-
github.event_name == 'workflow_dispatch' ||
(
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/testing ') &&
contains(fromJSON('["MEMBER","OWNER","COLLABORATOR"]'), github.event.comment.author_association)
)
steps:
- name: Parse comment
id: parse
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "platform=${{ github.event.inputs.platform }}" >> "$GITHUB_OUTPUT"
echo "pr_number=${{ github.event.inputs.pr_number }}" >> "$GITHUB_OUTPUT"
else
COMMENT="${{ github.event.comment.body }}"
PLATFORM="${COMMENT#/testing }"
echo "platform=${PLATFORM}" >> "$GITHUB_OUTPUT"
echo "pr_number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
fi
- name: Get PR details
id: pr
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_JSON=$(gh api repos/${{ github.repository }}/pulls/${{ steps.parse.outputs.pr_number }})
echo "ref=$(echo "$PR_JSON" | jq -r '.head.ref')" >> "$GITHUB_OUTPUT"
echo "repo=$(echo "$PR_JSON" | jq -r '.head.repo.full_name')" >> "$GITHUB_OUTPUT"
echo "sha=$(echo "$PR_JSON" | jq -r '.head.sha')" >> "$GITHUB_OUTPUT"
- name: Add reaction to comment
if: github.event_name != 'workflow_dispatch'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
-f content=rocket
- name: Dispatch to testing repo
env:
GH_TOKEN: ${{ secrets.OPENSERVERLESS_TESTING_PAT }}
run: |
gh api repos/${{ github.repository_owner }}/openserverless-testing/dispatches \
-X POST \
-f event_type=operator-pr-test \
-f 'client_payload[pr_number]=${{ steps.parse.outputs.pr_number }}' \
-f 'client_payload[pr_ref]=${{ steps.pr.outputs.ref }}' \
-f 'client_payload[pr_sha]=${{ steps.pr.outputs.sha }}' \
-f 'client_payload[operator_repo]=${{ steps.pr.outputs.repo }}' \
-f 'client_payload[platform]=${{ steps.parse.outputs.platform }}'