Skip to content

Merge branch 'ml4ai:main' into main #8

Merge branch 'ml4ai:main' into main

Merge branch 'ml4ai:main' into main #8

Workflow file for this run

---
# Automatically build Docker images on changes to main and push them to a
# Container Registry using HCL Bake file.
name: Build and Publish
on:
push:
branches: ['main']
tags: ['*']
jobs:
tag-generator:
name: Determine image tag
runs-on: ubuntu-22.04
outputs:
image-tag: ${{ steps.generate.outputs.tag }}
steps:
- name: Generate appropriate tag
id: generate
run: |
if [[ '${{ github.ref_type }}' == 'branch' && '${{ github.ref_name }}' == 'main' ]]; then
TAG=latest
else
SEMVER=$( echo ${{ github.ref_name }} | sed -nre 's/^v[^0-9]*(([0-9]+\.)*[0-9]+(-[a-z]+)?).*/\1/p')
if [[ -n $SEMVER ]]; then
TAG=${SEMVER}
else
TAG=${{ github.ref_name }}
fi
fi
echo "$TAG"
echo "tag=${TAG,,}" >> ${GITHUB_OUTPUT}
- name: Show Generated Tag
run: echo ${{ steps.generate.outputs.tag }}
make-dockerfile:
name: Create skema-text-reading Dockerfile
runs-on: ubuntu-22.04
needs:
- tag-generator
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Setup JDK (w/ SBT)
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- name: Generate Text Reading app and its Dockerfile
working-directory: ./skema/text_reading/scala
env:
APP_VERSION: steps.generate.outputs.tag
run: |
sbt "webapp/docker:stage"
# - name: Push to main
# run: |
# cd ${{ github.workspace }}
# git config user.name github-actions
# git config user.email github-actions@github.com
# git commit -am "generated text-reading"
# git push
# bake:
# needs:
# - tag-generator
# - make-dockerfile
# uses: darpa-askem/.github/.github/workflows/bake-publish.yaml@main
# with:
# file: 'docker-bake.hcl'
# group: 'tr'
# registry: 'ghcr.io'
# organization: ${{ github.repository_owner }}
# tag: ${{ needs.tag-generator.outputs.image-tag }}
# secrets:
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
- name: Create matrix
id: targets
run: |
docker buildx bake tr -f docker-bake.hcl --print
TARGETS=$(docker buildx bake tr -f docker-bake.hcl --print | jq -cr ".group.tr.targets")
echo "matrix=$TARGETS" >> $GITHUB_OUTPUT
# 1.3 (optional) - output the generated target list for verification
- name: Show matrix
run: |
echo ${{ steps.targets.outputs.matrix }}
- name: set env variables for bakefile
run: |
# Lowercase the inputs for Docker image naming conventions
TAG=${{ needs.tag-generator.outputs.image-tag }}
ORG=${{ github.repository_owner }}
REG=ghcr.io
echo "VERSION=${TAG,,}" >> ${GITHUB_ENV}
echo "DOCKER_REGISTRY=${REG,,}" >> ${GITHUB_ENV}
echo "DOCKER_ORG=${ORG,,}" >> ${GITHUB_ENV}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Build Images using BuildX Bake
uses: docker/bake-action@v2
with:
files: ./docker-bake.hcl
targets: ${{ matrix.target }}
no-cache: false
push: true
set: |
*.cache-from=type=gha,scope=build-${{ matrix.target }}
*.cache-to=type=gha,scope=build-${{ matrix.target }},mode=max