Skip to content

odm-platform CI/CD

odm-platform CI/CD #96

Workflow file for this run

name: odm-platform CI/CD
on:
release:
types: [ created ]
env:
REGISTRY_IMAGE_NAME: odm-platform-registry
DEVOPS_IMAGE_NAME: odm-platform-devops
BLUEPRINT_IMAGE_NAME: odm-platform-blueprint
POLICY_IMAGE_NAME: odm-platform-policy
NOTIFICATION_IMAGE_NAME: odm-platform-notification
PARAMS_IMAGE_NAME: odm-platform-params
jobs:
verify-version:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
ssh-key: ${{secrets.SSH_KEY}}
- name: Install SSH key # Install SSH key to connect to GitHub repos
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Get Git Tag
run: echo "TAG_VERSION=$( echo ${{github.ref_name}} | sed 's/[^0-9.]//g' )" >> $GITHUB_ENV
- name: Get Maven Version
run: echo "MAVEN_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Check Tag and Version Match
run: |
if [ "${{ env.TAG_VERSION }}" != "${{ env.MAVEN_VERSION }}" ]; then
echo "Git tag (${{ env.TAG_VERSION }}) does not match POM version (${{ env.MAVEN_VERSION }})"
exit 1
fi
- name: Execute tests with Maven
run: |
mvn -B test -Dspring.profiles.active=test
mvn -B test -Dspring.profiles.active=testpostgresql
mvn -B test -Dspring.profiles.active=testmysql
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-maven-packages:
runs-on: ubuntu-latest
needs: verify-version
permissions:
contents: read
packages: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Publish Maven package
run: mvn -DskipTests -DGitHubPackages=true --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-docker-images:
runs-on: ubuntu-latest
needs: verify-version
permissions:
contents: read
packages: write
steps:
- name: Get Git Tag
run: echo "TAG_VERSION=$( echo ${{github.ref_name}} | sed 's/[^0-9.]//g' )" >> $GITHUB_ENV
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build Maven package
run: mvn install -DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker images
run: |
docker build . --file Dockerfile --tag $REGISTRY_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker build . --file product-plane-services/devops-server/Dockerfile --tag $DEVOPS_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker build . --file product-plane-services/blueprint-server/Dockerfile --tag $BLUEPRINT_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker build . --file product-plane-services/policy-server/Dockerfile --tag $POLICY_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker build . --file product-plane-services/notification-server/Dockerfile --tag $NOTIFICATION_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
docker build . --file product-plane-services/params-server/Dockerfile --tag $PARAMS_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push images to GitHub Container Registry
run: |
IMAGE_ID=ghcr.io/opendatamesh-initiative/odm-platform-registry
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
docker tag $REGISTRY_IMAGE_NAME $IMAGE_ID:${{ env.TAG_VERSION }}
docker push $IMAGE_ID:${{ env.TAG_VERSION }}
IMAGE_ID=ghcr.io/opendatamesh-initiative/odm-platform-devops
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
docker tag $DEVOPS_IMAGE_NAME $IMAGE_ID:${{ env.TAG_VERSION }}
docker push $IMAGE_ID:${{ env.TAG_VERSION }}
IMAGE_ID=ghcr.io/opendatamesh-initiative/odm-platform-blueprint
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
docker tag $BLUEPRINT_IMAGE_NAME $IMAGE_ID:${{ env.TAG_VERSION }}
docker push $IMAGE_ID:${{ env.TAG_VERSION }}
IMAGE_ID=ghcr.io/opendatamesh-initiative/odm-platform-policy
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
docker tag $POLICY_IMAGE_NAME $IMAGE_ID:${{ env.TAG_VERSION }}
docker push $IMAGE_ID:${{ env.TAG_VERSION }}
IMAGE_ID=ghcr.io/opendatamesh-initiative/odm-platform-notification
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
docker tag $NOTIFICATION_IMAGE_NAME $IMAGE_ID:${{ env.TAG_VERSION }}
docker push $IMAGE_ID:${{ env.TAG_VERSION }}
IMAGE_ID=ghcr.io/opendatamesh-initiative/odm-platform-params
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
docker tag $PARAMS_IMAGE_NAME $IMAGE_ID:${{ env.TAG_VERSION }}
docker push $IMAGE_ID:${{ env.TAG_VERSION }}
- name: DockerHub login
env:
DOCKER_USER: ${{secrets.DOCKER_USERNAME}}
DOCKER_PWD: ${{secrets.DOCKER_PASSWORD}}
run: docker login -u $DOCKER_USER -p $DOCKER_PWD
- name: DockerHub images build
run: |
docker build . --file Dockerfile --tag opendatamesh/odm-platform-registry:${{ env.TAG_VERSION }}
docker build . --file product-plane-services/devops-server/Dockerfile --tag opendatamesh/odm-platform-devops:${{ env.TAG_VERSION }}
docker build . --file product-plane-services/blueprint-server/Dockerfile --tag opendatamesh/odm-platform-blueprint:${{ env.TAG_VERSION }}
docker build . --file product-plane-services/policy-server/Dockerfile --tag opendatamesh/odm-platform-policy:${{ env.TAG_VERSION }}
docker build . --file product-plane-services/notification-server/Dockerfile --tag opendatamesh/odm-platform-notification:${{ env.TAG_VERSION }}
- name: DockerHub images push
run: |
docker push opendatamesh/odm-platform-registry:${{ env.TAG_VERSION }}
docker push opendatamesh/odm-platform-devops:${{ env.TAG_VERSION }}
docker push opendatamesh/odm-platform-blueprint:${{ env.TAG_VERSION }}
docker push opendatamesh/odm-platform-policy:${{ env.TAG_VERSION }}
docker push opendatamesh/odm-platform-notification:${{ env.TAG_VERSION }}
publish-api-doc:
runs-on: ubuntu-latest
needs: verify-version
permissions:
contents: write
packages: read
steps:
- name: Get Git Tag
run: echo "TAG_VERSION=$( echo ${{github.ref_name}} | sed 's/[^0-9.]//g' )" >> $GITHUB_ENV
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Set up node
uses: actions/setup-node@v4
- name: Install Redocly CLI
run: npm install -g @redocly/cli@latest
- name: Set Git user
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Publish API doc
run: |
./generate-full-redoc-static-html.sh
./upload-redoc-static-html-to-github.sh ${{ env.TAG_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}