Skip to content

feat(build): added build-push-container-images.yml #4

feat(build): added build-push-container-images.yml

feat(build): added build-push-container-images.yml #4

name: Build and Push Container Images
on:
push:
branches:
- master
permissions:
contents: read
packages: write
env:
JAVA_VERSION: "21"
DISTRIBUTION: "corretto"
CONTAINER_REGISTRY: "ghcr.io"
CONTAINER_GROUP: "cloudeko/services"
MODULE_NAME: "zenei"
jobs:
build-and-push:
strategy:
matrix:
include:
- type: jvm
build_args: "-Dquarkus.container-image.build=true"
group: ${{ env.CONTAINER_GROUP }}

Check failure on line 26 in .github/workflows/build-push-container-images.yml

View workflow run for this annotation

GitHub Actions / Build and Push Container Images

Invalid workflow file

The workflow is not valid. .github/workflows/build-push-container-images.yml (Line: 26, Col: 20): Unrecognized named-value: 'env'. Located at position 1 within expression: env.CONTAINER_GROUP .github/workflows/build-push-container-images.yml (Line: 29, Col: 20): Unrecognized named-value: 'env'. Located at position 1 within expression: env.CONTAINER_GROUP
- type: native
build_args: "-Dnative -Dquarkus.native.container-build=true"
group: ${{ env.CONTAINER_GROUP }}/native
name: Build and Push ${{ matrix.type }} Image
environment: development
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Maven Dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.DISTRIBUTION }}
cache: maven
- name: Calculate Short SHA and Image Name
id: meta
run: |
echo "short_sha=$(echo $GITHUB_SHA | head -c7)" >> $GITHUB_OUTPUT
IMAGE_NAME=$(echo "${{ env.MODULE_NAME }}" | sed -r 's/([a-z])([A-Z])/\1-\2/g' | tr '[:upper:]' '[:lower:]')
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
- name: Set Maven Version
run: mvn versions:set -DnewVersion=${{ steps.meta.outputs.short_sha }}
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.CONTAINER_REGISTRY }} -u ${{ github.actor }} --password-stdin
- name: Build and push image
run: |
mvn clean install -DskipTests \
${{ matrix.build_args }} \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.registry=${{ env.CONTAINER_REGISTRY }} \
-Dquarkus.container-image.group=${{ matrix.group }} \
-Dquarkus.container-image.name=${{ steps.meta.outputs.image_name }} \
-Dquarkus.container-image.tag=${{ steps.meta.outputs.short_sha }}