Skip to content

publishing docker image to registry #7

publishing docker image to registry

publishing docker image to registry #7

Workflow file for this run

# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Publish to cdoc2-shares-server GitHub Registry
on:
push:
branches: ["test"]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
settings-path: ${{ github.workspace }} # location for the settings.xml file
# test if username and password are correct (may still fail if no write access or wrong package name)
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build Docker/OCI images and publish to GH Container registry (ghcr.io)
run: |
mvn clean install -s $GITHUB_WORKSPACE/settings.xml -Dmaven.test.skip=true --batch-mode
mvn spring-boot:build-image -f shares-server \
-s $GITHUB_WORKSPACE/settings.xml --batch-mode \
-Dmaven.test.skip=true \
-Dspring-boot.build-image.publish=true \
-Ddocker.publishRegistry.url=${REGISTRY} \
-Ddocker.publishRegistry.username=${USERNAME} \
-Ddocker.publishRegistry.password=${GITHUB_TOKEN} \
-Dspring-boot.build-image.imageName=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-shares-server:${TAG}-${GITHUB_SHA} \
-Dspring-boot.build-image.tags=${REGISTRY}/${GITHUB_REPOSITORY_OWNER}/cdoc2-shares-server:latest
env:
REGISTRY: ghcr.io
USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ github.token }}
# Note: git tag can contain more symbols than Container registry, allowed for docker tag:
# lowercase and uppercase letters, digits, underscores, periods, and hyphens.
# Note: imageName tag is built from git tag which can be different from module version
TAG: "0.1.0"
# use open-eid Maven repo for dependencies download, see pom.xml
MAVEN_REPO: open-eid/cdoc2-shares-server