Build and push UI image #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push UI image | |
# Note: this is not used on main, but needs to be on the default branch so it can be manually triggered | |
env: | |
LATEST_IMAGE_TAG: "latest" | |
IMAGE_BASE_NAME: "quay.io/quarkus-super-heroes" | |
DEFAULT_BRANCH: rhbq-2.13 | |
on: | |
schedule: | |
# 1am every Sunday | |
- cron: '0 1 * * 0' | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: The branch to build/push | |
required: true | |
type: string | |
default: rhbq-2.13 | |
workflow_call: | |
inputs: | |
branch: | |
description: The branch to build/push | |
required: true | |
type: string | |
default: rhbq-2.13 | |
jobs: | |
build-push-ui-images: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set variable defaults | |
run: echo "BRANCH=${{ github.event.inputs.branch || env.DEFAULT_BRANCH }}" >> $GITHUB_ENV | |
- name: Checkout from ${{ env.BRANCH }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.BRANCH }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
cache: maven | |
- name: Calculate Tags (main branch) | |
if: env.BRANCH == 'main' | |
working-directory: ui-super-heroes | |
run: | | |
echo "CONTAINER_TAG=${{ env.LATEST_IMAGE_TAG }}" >> $GITHUB_ENV && | |
echo "APP_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
- name: Calculate Tags (other branch) | |
if: env.BRANCH != 'main' | |
working-directory: ui-super-heroes | |
run: | | |
echo "CONTAINER_TAG=${{ env.LATEST_IMAGE_TAG }}-${{ env.BRANCH }}" >> $GITHUB_ENV && | |
echo "APP_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)-${{ env.BRANCH }}" >> $GITHUB_ENV | |
- name: Login to quay | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_REPO_USERNAME }} | |
password: ${{ secrets.QUAY_REPO_TOKEN }} | |
- name: Build and push UI image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ui-super-heroes | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ env.IMAGE_BASE_NAME }}/ui-super-heroes:${{ env.CONTAINER_TAG }},${{ env.IMAGE_BASE_NAME }}/ui-super-heroes:${{ env.APP_VERSION }} |