Skip to content

Commit 23809fa

Browse files
rsoaresdKubeSawmfrancisc
authored
add workflow for publishing the Developer Sandbox UI for UI E2E testing (codeready-toolchain#1181)
* add workflows * change * improvements * improvements * requested changes by coderabbitai * requested changes by coderabbitai * requested changes * requested changes * requested changes * requested changes * fix * update uses: actions/checkout@v4 to uses: actions/checkout@v5 --------- Co-authored-by: KubeSaw <devsandbox@redhat.com> Co-authored-by: Francisc Munteanu <fmuntean@redhat.com>
1 parent 1c62a70 commit 23809fa

File tree

2 files changed

+116
-12
lines changed

2 files changed

+116
-12
lines changed

.github/workflows/publish-operators-for-e2e-tests.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
pull_request_target:
66
types: [opened, synchronize, reopened, ready_for_review]
77

8+
permissions:
9+
contents: read
10+
811
env:
912
GOPATH: /tmp/go
1013

@@ -13,33 +16,37 @@ jobs:
1316
name: Build & push operator bundles for e2e tests
1417

1518
runs-on: ubuntu-24.04
16-
if: ${{ github.event.comment == '' || contains(github.event.comment.body, '/retest') || contains(github.event.comment.body, '/test all') || contains(github.event.comment.body, '/test e2e') }}
19+
if: >-
20+
${{ github.event_name == 'pull_request_target' ||
21+
(github.event_name == 'issue_comment' &&
22+
(contains(github.event.comment.body, '/retest') ||
23+
contains(github.event.comment.body, '/test all') ||
24+
contains(github.event.comment.body, '/test e2e'))) }}
1725
steps:
18-
# Checkout from PR event - in that case the comment field is empty
26+
# Checkout from PR event
1927
- name: Checkout code from PR event
2028
uses: actions/checkout@v5
21-
if: ${{ github.event.comment == '' }}
29+
if: ${{ github.event_name == 'pull_request_target' }}
2230
with:
2331
ref: ${{github.event.pull_request.head.ref}}
2432
repository: ${{github.event.pull_request.head.repo.full_name}}
2533
fetch-depth: 0
2634

2735
# If the workflow was triggered based on comment, then we need to get the information about the PR
28-
# Is executed only for comment events - in that case the pull_request field is empty
2936
- name: Send Github API Request to get PR data
3037
id: request
3138
uses: octokit/request-action@v2.4.0
32-
if: ${{ github.event.pull_request == '' }}
39+
if: ${{ github.event_name == 'issue_comment' }}
3340
with:
3441
route: ${{ github.event.issue.pull_request.url }}
3542
env:
3643
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3744

3845
# Checkout the code based on the data retrieved from the previous step
39-
# Is executed only for comment events - in that case the pull_request field is empty
46+
# Is executed only for comment events
4047
- name: Checkout code from PR
4148
uses: actions/checkout@v5
42-
if: ${{ github.event.pull_request == '' }}
49+
if: ${{ github.event_name == 'issue_comment' }}
4350
with:
4451
repository: ${{ fromJson(steps.request.outputs.data).head.repo.full_name }}
4552
ref: ${{ fromJson(steps.request.outputs.data).head.ref }}
@@ -54,7 +61,7 @@ jobs:
5461
uses: actions/cache@v4
5562
with:
5663
path: ~/go/pkg/mod
57-
key: ${{ runner.os }}-go-${{ hashFiles ('**/go.sum') }}
64+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
5865
restore-keys: |
5966
${{ runner.os }}-go-
6067
@@ -66,10 +73,9 @@ jobs:
6673
uses: codeready-toolchain/toolchain-cicd/prepare-tools-action@master
6774

6875
# Execute composite action using values from PR event
69-
# Is executed only for PR events - in that case the comment field is empty
7076
- name: Publish current operator bundles for host & member based on PR event
7177
uses: codeready-toolchain/toolchain-cicd/publish-operators-for-e2e-tests@master
72-
if: ${{ github.event.comment == '' }}
78+
if: ${{ github.event_name == 'pull_request_target' }}
7379
with:
7480
quay-token: ${{ secrets.TEST_QUAY_TOKEN }}
7581
quay-namespace: codeready-toolchain-test
@@ -79,10 +85,9 @@ jobs:
7985
gh-head-ref: ${{ github.event.pull_request.head.ref }}
8086

8187
# Execute composite action using values from PR event
82-
# Is executed only for comment events - in that case the pull_request field is empty
8388
- name: Publish current operator bundles for host & member based on comment event
8489
uses: codeready-toolchain/toolchain-cicd/publish-operators-for-e2e-tests@master
85-
if: ${{ github.event.pull_request == '' }}
90+
if: ${{ github.event_name == 'issue_comment' }}
8691
with:
8792
quay-token: ${{ secrets.TEST_QUAY_TOKEN }}
8893
quay-namespace: codeready-toolchain-test
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: publish-sandbox-ui-for-ui-e2e-tests
2+
on:
3+
issue_comment:
4+
types: [created]
5+
pull_request_target:
6+
types: [opened, synchronize, reopened, ready_for_review]
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
11+
12+
jobs:
13+
publish-sandbox-ui-for-ui-e2e-tests:
14+
name: Build & push Developer Sandbox UI image for UI e2e tests
15+
16+
runs-on: ubuntu-24.04
17+
if: >-
18+
${{ github.event_name == 'pull_request_target' ||
19+
(github.event_name == 'issue_comment' &&
20+
(contains(github.event.comment.body, '/retest') ||
21+
contains(github.event.comment.body, '/test all') ||
22+
contains(github.event.comment.body, '/test e2e'))) }}
23+
steps:
24+
# Checkout from PR event
25+
- name: Checkout code from PR event
26+
uses: actions/checkout@v5
27+
if: ${{ github.event_name == 'pull_request_target' }}
28+
with:
29+
ref: ${{github.event.pull_request.head.ref}}
30+
repository: ${{github.event.pull_request.head.repo.full_name}}
31+
fetch-depth: 0
32+
33+
# If the workflow was triggered based on comment, then we need to get the information about the PR
34+
- name: Send Github API Request to get PR data
35+
id: request
36+
uses: octokit/request-action@v2.4.0
37+
if: ${{ github.event_name == 'issue_comment' }}
38+
with:
39+
route: ${{ github.event.issue.pull_request.url }}
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
# Checkout the code based on the data retrieved from the previous step
44+
# Is executed only for comment events
45+
- name: Checkout code from PR
46+
uses: actions/checkout@v5
47+
if: ${{ github.event_name == 'issue_comment' }}
48+
with:
49+
repository: ${{ fromJson(steps.request.outputs.data).head.repo.full_name }}
50+
ref: ${{ fromJson(steps.request.outputs.data).head.ref }}
51+
fetch-depth: 0
52+
53+
- name: Install Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version-file: go.mod
57+
58+
- name: Cache dependencies
59+
uses: actions/cache@v4
60+
with:
61+
path: ~/go/pkg/mod
62+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
63+
restore-keys: |
64+
${{ runner.os }}-go-
65+
66+
- uses: actions/setup-python@v5
67+
with:
68+
python-version: "3.x"
69+
70+
- name: Prepare tools
71+
uses: codeready-toolchain/toolchain-cicd/prepare-tools-action@master
72+
73+
# Login to quay for PR events
74+
- name: Login to quay (PR event)
75+
if: ${{ github.event_name == 'pull_request_target' }}
76+
run: |
77+
set -e
78+
export XDG_RUNTIME_DIR=/run/user/${UID}
79+
mkdir -p ${XDG_RUNTIME_DIR}/containers || true
80+
echo "{
81+
\"auths\": {
82+
\"quay.io\": {
83+
\"auth\": \"${{ secrets.TEST_QUAY_TOKEN }}\"
84+
}
85+
}
86+
}"> ${XDG_RUNTIME_DIR}/containers/auth.json
87+
podman login --get-login quay.io
88+
89+
# Publish Developer Sandbox UI for PR events
90+
- name: Publish current Developer Sandbox UI (PR event)
91+
if: ${{ github.event_name == 'pull_request_target' }}
92+
run: |
93+
make push-sandbox-plugin QUAY_NAMESPACE=codeready-toolchain-test IMAGE_BUILDER=podman PULL_PULL_SHA=${{ github.event.pull_request.head.sha }} PULL_NUMBER=${{ github.event.pull_request.number }} AUTHOR=${{ github.event.pull_request.head.user.login }} BRANCH_NAME=${{ github.event.pull_request.head.ref }}
94+
95+
# Publish Developer Sandbox UI for comment events
96+
- name: Publish current Developer Sandbox UI (comment event)
97+
if: ${{ github.event_name == 'issue_comment' }}
98+
run: |
99+
make push-sandbox-plugin QUAY_NAMESPACE=codeready-toolchain-test IMAGE_BUILDER=podman PULL_PULL_SHA=${{ fromJson(steps.request.outputs.data).head.sha }} PULL_NUMBER=${{ fromJson(steps.request.outputs.data).number }} AUTHOR=${{ fromJson(steps.request.outputs.data).head.user.login }} BRANCH_NAME=${{ fromJson(steps.request.outputs.data).head.ref }}

0 commit comments

Comments
 (0)