Skip to content

Commit 5fdc38b

Browse files
authored
chore(e2e): enable GH action for building e2e runner in 1.4 branch too (#2560)
Signed-off-by: Nick Boldt <[email protected]>
1 parent 6a57102 commit 5fdc38b

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

.github/actions/get-sha/action.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2024 The Janus IDP Authors
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Get the last commit short SHA
16+
description: Get the last commit short SHA of the main branch or PR
17+
18+
outputs:
19+
short_sha:
20+
description: The short SHA of the last commit
21+
value: ${{ steps.build.outputs.sha }}
22+
23+
24+
runs:
25+
using: composite
26+
steps:
27+
- name: Get the last commit short SHA
28+
shell: bash
29+
run: |
30+
if [[ -n "${{ github.event.pull_request.head.sha }}" ]]; then
31+
# running on a PR
32+
REF="${{ github.event.pull_request.head.sha }}"
33+
REPO="${{ github.repository }}/pull/${{ github.event.number }}"
34+
else
35+
# running on a main branch
36+
# todo: handle other branches than main
37+
REF="HEAD"
38+
REPO="${{ github.repository }}"
39+
fi
40+
SHORT_SHA=$(git rev-parse --short=8 $REF)
41+
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_ENV
42+
if [[ -f packages/app/src/build-metadata.json ]]; then
43+
now="$(date -u +%FT%TZ)"
44+
sed -i packages/app/src/build-metadata.json -r \
45+
-e 's|("Last Commit:.+)|"Last Commit: '$REPO' @ '$SHORT_SHA'"|'
46+
fi
47+
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Build & Push e2e-runner Image to Quay.io
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-1.**
8+
paths:
9+
- '.ibm/images/Dockerfile'
10+
- '.yarnrc.yml'
11+
workflow_dispatch:
12+
inputs:
13+
branch:
14+
description: Target branch to build
15+
required: true
16+
default: 'NONE'
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
22+
env:
23+
REGISTRY: quay.io
24+
REGISTRY_IMAGE: rhdh-community/rhdh-e2e-runner
25+
26+
jobs:
27+
build-image:
28+
name: Build & Push e2e-runner Image
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [ubuntu-24.04]
33+
runs-on: ${{ matrix.os }}
34+
permissions:
35+
contents: read
36+
packages: write
37+
38+
steps:
39+
- name: Checkout Repository
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0
43+
44+
- name: Prepare Environment Variables
45+
run: |
46+
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV
47+
48+
# create image tag from the correct branch (either from a push or a workflow_dispatch trigger)
49+
if [[ "${{ inputs.branch }}" ]] && [[ "${{ inputs.branch }}" != "NONE" ]]; then
50+
echo "Switch to ${{ inputs.branch }}"
51+
git checkout "${{ inputs.branch }}"
52+
IMAGE_TAG="${{ inputs.branch }}"
53+
else
54+
echo "Use current branch ${{ github.ref }}"
55+
IMAGE_TAG=$(git rev-parse --abbrev-ref HEAD)
56+
fi
57+
echo "Use IMAGE_TAG = $IMAGE_TAG"
58+
echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV
59+
60+
- name: Get the last commit short SHA
61+
uses: ./.github/actions/get-sha
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Login to Quay.io
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ${{ env.REGISTRY }}
70+
username: ${{ secrets.QUAY_USERNAME }}
71+
password: ${{ secrets.QUAY_TOKEN }}
72+
73+
- name: Build and Push Image
74+
uses: docker/build-push-action@v5
75+
with:
76+
context: .
77+
file: .ibm/images/Dockerfile
78+
push: true
79+
tags: |
80+
${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}
81+
${{ env.REGISTRY }}/${{ env.REGISTRY_IMAGE }}:${{ env.IMAGE_TAG }}-${{ env.SHORT_SHA }}
82+
platforms: ${{ env.PLATFORM }}

.ibm/images/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Base image from Microsoft Playwright
2+
# DO NOT UPDATE to 1.49 or newer -- must stay pinned to Nodejs 20!
23
FROM mcr.microsoft.com/playwright:v1.47.2-jammy
34

45
# Set environment variables for the container

0 commit comments

Comments
 (0)