Skip to content

Commit

Permalink
ci: add additional pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jobulcke committed Dec 5, 2024
1 parent 147a005 commit c1b8d30
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 1 deletion.
194 changes: 194 additions & 0 deletions .github/workflows/build-image-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
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
2 changes: 1 addition & 1 deletion .github/workflows/pr-merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
id: determine-version
run: |
export VERSION=$(mvn help:evaluate -Dexpression="project.version" -q -DforceStdout)
echo "::set-output name=version::$VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Analyse & publish package
run: |
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar deploy -Dsonar.projectKey=Informatievlaanderen_VSDS-Linked-Data-Interactions -Pcoverage,release -Dparallel=all -DperCoreThreadCount=true
Expand Down

0 comments on commit c1b8d30

Please sign in to comment.