Skip to content

feat(ct): add additional tags for base images #428

feat(ct): add additional tags for base images

feat(ct): add additional tags for base images #428

---
name: Base Container Image
on:
push:
tags:
- 'v[6-9].*'
branches:
- 'develop'
- '10478-version-base-img'
paths:
- 'modules/container-base/**'
- 'modules/dataverse-parent/pom.xml'
- '.github/workflows/container_base_push.yml'
schedule:
- cron: '23 3 * * 0' # Run for 'develop' every Sunday at 03:23 UTC
env:
PLATFORMS: linux/amd64,linux/arm64
jobs:
discover:
name: Discover Release Matrix
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
# Only run in upstream repo - avoid unnecessary runs in forks and only for scheduled
if: ${{ github.repository_owner == 'IQSS' }}
outputs:
branches: ${{ steps.matrix.outputs.branches }}
steps:
- name: Build branch matrix options
id: matrix
run: |
# Get last three releases and include develop branch as matrix elements
#if [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "branches=$(curl -f -sS https://api.github.com/repos/IQSS/dataverse/releases | \
jq '[ .[0:3] | .[].tag_name, "develop" ]')" | tr -d "\n" | tr -s " " | \
tee -a "$GITHUB_OUTPUT"
#else
# echo "branches=['develop']" | tee -a "$GITHUB_OUTPUT"
#fi
build:
name: Build image
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
needs: discover
strategy:
fail-fast: false
matrix:
branch: ${{ fromJson(needs.discover.outputs.branches) }}
# Only run in upstream repo - avoid unnecessary runs in forks
if: ${{ github.repository_owner == 'IQSS' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
- name: Determine Java version from Parent POM
run: |
echo "JAVA_VERSION=$(grep '<target.java.version>' modules/dataverse-parent/pom.xml | cut -f2 -d'>' | cut -f1 -d'<')" >> ${GITHUB_ENV}
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: 'maven'
cache-dependency-path: |
modules/container-base/pom.xml
# Note: Accessing, pushing tags etc. to DockerHub will only succeed in upstream and
# on events in context of upstream because secrets. PRs run in context of forks by default!
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up QEMU for multi-arch builds
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.PLATFORMS }}
- name: Add additional tags as options
run: |
# For the development branch, update the latest tag in addition
if [[ "${{ matrix.branch }}" == "develop" ]]; then
echo "DOCKER_TAGS='-Ddocker.tags.develop=latest'" | tee -a "${GITHUB_ENV}"
# In case of releases <=6.2, we still need to provide backward compatible names "alpha" and "unstable"
elif [[ "${{ matrix.branch }}" == "v6.2" ]]; then
echo "DOCKER_TAGS='-Ddocker.tags.additional=alpha'" | tee -a "${GITHUB_ENV}"
fi
- name: Deploy multi-arch base container image to Docker Hub
# Do not build for v6.0 and v6.1. We can simply reuse the one from v6.2.
if: ${{ matrix.branch != 'v6.0' && matrix.branch != 'v6.1' }}
run: mvn -f modules/container-base -Pct deploy -Ddocker.skip.push ${DOCKER_TAGS} -Ddocker.platforms=${{ env.PLATFORMS }}
- if: ${{ github.event_name == 'push' && github.ref_name == 'develop' }}
name: Push description to DockerHub
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: gdcc/base
short-description: "Dataverse Base Container image providing Payara application server and optimized configuration"
readme-filepath: ./modules/container-base/README.md
push-app-img:
name: "Rebase & Publish App Image"
permissions:
contents: read
packages: write
pull-requests: write
needs: build
# We do not release a new base image for pull requests, so do not trigger.
# if: ${{ github.event_name != 'pull_request' }}
uses: ./.github/workflows/container_app_push.yml
secrets: inherit