2.b Build & Push Image Only #1
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: 2.b Build & Push Image Only | |
on: | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
LDIO_IMAGE_NAME: ldi-orchestrator | |
DISCOVERER_IMAGE_NAME: ldes-discoverer | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
outputs: | |
version: ${{ steps.determine-version.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: zulu | |
java-version: 21 | |
- name: Cache SonarCloud packages | |
uses: actions/[email protected] | |
with: | |
path: ~/.sonar/cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache Maven packages | |
uses: actions/[email protected] | |
with: | |
path: ~/.m2 | |
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-m2 | |
# Maven | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21 | |
distribution: 'zulu' | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Determine version | |
id: determine-version | |
run: | | |
export VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout) | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: Analyse & publish package | |
run: | | |
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=Informatievlaanderen_VSDS-Linked-Data-Interactions -Pcoverage,release -Dparallel=all -DperCoreThreadCount=true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | |
- name: Upload JARs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts | |
path: | | |
**/*with-dependencies.jar | |
**/*application.jar | |
**/ldes-discoverer.jar | |
create-ldio-image: | |
name: Build and push LDIO image | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Download JARs | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: .github | |
- name: Define docker variables | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
echo "IMAGE_TAG=${{ needs.build.outputs.version }}" >> $GITHUB_ENV | |
echo "IMAGES=ldes/${{ env.LDIO_IMAGE_NAME }}" >> $GITHUB_ENV | |
if [[ "${{ needs.build.outputs.version }}" != *"SNAPSHOT"* ]]; then | |
echo "LATEST=latest" >> $GITHUB_ENV | |
fi | |
else | |
echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
echo "IMAGES=${{ env.REGISTRY }}/Informatievlaanderen/${{ env.LDIO_IMAGE_NAME }}" >> $GITHUB_ENV | |
echo "LATEST=latest" >> $GITHUB_ENV | |
fi | |
- name: Log in to the DockerHub Container registry | |
if: github.ref_name == 'main' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to the GitHub Container registry | |
if: github.ref_name != 'main' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: Informatievlaanderen | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGES }} | |
tags: | | |
type=raw,value=${{env.IMAGE_TAG}} | |
type=raw,value=${{env.LATEST}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: .github | |
push: true | |
file: .github/ldio.Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
platforms: linux/amd64,linux/arm64 | |
create-discoverer-image: | |
name: Build and push LDES Discoverer image | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Download JARs | |
uses: actions/download-artifact@v4 | |
with: | |
name: artifacts | |
path: .github | |
- name: Define docker variables | |
run: | | |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
echo "IMAGE_TAG=${{ needs.build.outputs.version }}" >> $GITHUB_ENV | |
echo "IMAGES=ldes/${{ env.DISCOVERER_IMAGE_NAME }}" >> $GITHUB_ENV | |
if [[ "${{ needs.build.outputs.version }}" != *"SNAPSHOT"* ]]; then | |
echo "LATEST=latest" >> $GITHUB_ENV | |
fi | |
else | |
echo "IMAGE_TAG=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV | |
echo "IMAGES=${{ env.REGISTRY }}/Informatievlaanderen/${{ env.DISCOVERER_IMAGE_NAME }}" >> $GITHUB_ENV | |
echo "LATEST=latest" >> $GITHUB_ENV | |
fi | |
- name: Log in to the DockerHub Container registry | |
if: github.ref_name == 'main' | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to the GitHub Container registry | |
if: github.ref_name != 'main' | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: Informatievlaanderen | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.IMAGES }} | |
tags: | | |
type=raw,value=${{env.IMAGE_TAG}} | |
type=raw,value=${{env.LATEST}} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v3 | |
with: | |
context: .github | |
push: true | |
file: .github/ldes-discoverer.Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
platforms: linux/amd64,linux/arm64 |