This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
Bump quarkus.platform.version from 2.16.3.Final to 3.6.7 in /apis/java/quarkus-legacy-oracle #51
Workflow file for this run
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
# 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. | |
# 💁 The OpenShift Starter workflow will: | |
# - Checkout your repository | |
# - Perform a container image build | |
# - Push the built image to the GitHub Container Registry (GHCR) | |
# - Log in to your OpenShift cluster | |
# - Create an OpenShift app from the image and expose it to the internet | |
# ℹ️ Configure your repository and the workflow with the following steps: | |
# 1. Have access to an OpenShift cluster. Refer to https://www.openshift.com/try | |
# 2. Create the OPENSHIFT_SERVER and OPENSHIFT_TOKEN repository secrets. Refer to: | |
# - https://github.com/redhat-actions/oc-login#readme | |
# - https://docs.github.com/en/actions/reference/encrypted-secrets | |
# - https://cli.github.com/manual/gh_secret_set | |
# 3. (Optional) Edit the top-level 'env' section as marked with '🖊️' if the defaults are not suitable for your project. | |
# 4. (Optional) Edit the build-image step to build your project. | |
# The default build type is by using a Dockerfile at the root of the repository, | |
# but can be replaced with a different file, a source-to-image build, or a step-by-step buildah build. | |
# 5. Commit and push the workflow file to your default branch to trigger a workflow run. | |
# 👋 Visit our GitHub organization at https://github.com/redhat-actions/ to see our actions and provide feedback. | |
name: openshift-java-quarkus-oracle | |
env: | |
# 🖊️ EDIT your repository secrets to log into your OpenShift cluster and set up the context. | |
# See https://github.com/redhat-actions/oc-login#readme for how to retrieve these values. | |
# To get a permanent token, refer to https://github.com/redhat-actions/oc-login/wiki/Using-a-Service-Account-for-GitHub-Actions | |
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }} | |
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | |
# 🖊️ EDIT to set the kube context's namespace after login. Leave blank to use your user's default namespace. | |
OPENSHIFT_NAMESPACE_NO_ENV: ${{ secrets.NAMESPACE_NO_ENV}} | |
# 🖊️ EDIT with the port your application should be accessible on. | |
# If the container image exposes *exactly one* port, this can be left blank. | |
# Refer to the 'port' input of https://github.com/redhat-actions/oc-new-app | |
APP_PORT: "" | |
# 🖊️ EDIT to change the image registry settings. | |
# Registries such as GHCR, Quay.io, and Docker Hub are supported. | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}/nr-arch-templates | |
IMAGE_REGISTRY_USER: ${{ github.actor }} | |
IMAGE_REGISTRY_PASSWORD: ${{ github.token }} | |
OIDC_AUTH_SERVER_URL: ${{ secrets.OIDC_AUTH_SERVER_URL }} | |
DB_HOST: ${{ secrets.DB_HOST }} | |
DB_PORT: ${{ secrets.DB_PORT }} | |
FILE_LOG_LEVEL: ${{ secrets.FILE_LOG_LEVEL }} | |
QUARKUS_DATASOURCE_JDBC_PASSWORD: ${{ secrets.QUARKUS_DATASOURCE_JDBC_PASSWORD }} | |
QUARKUS_DATASOURCE_JDBC_USERNAME: ${{ secrets.QUARKUS_DATASOURCE_JDBC_USERNAME }} | |
SERVICE_NAME: ${{ secrets.SERVICE_NAME }} | |
# 🖊️ EDIT to specify custom tags for the container image, or default tags will be generated below. | |
IMAGE_TAGS: "" | |
DOCKER_ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca/docker-remote | |
ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca | |
APP_NAME: 'quarkus-api-oracle' | |
REPO_NAME: "nr-arch-templates" | |
JOB_NAME: "main" | |
NAMESPACE: ${{ secrets.NAMESPACE_NO_ENV }} | |
TAG: "latest" | |
TARGET_ENV: "dev" | |
MIN_REPLICAS: "2" | |
MAX_REPLICAS: "2" | |
MIN_CPU: "50m" | |
MAX_CPU: "1000m" | |
MIN_MEM: "125Mi" | |
MAX_MEM: "350Mi" | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'apis/java/quarkus-legacy-oracle/**' | |
jobs: | |
openshift-ci-cd: | |
name: Build and deploy to OpenShift | |
runs-on: ubuntu-22.04 | |
environment: quarkus-oracle-dev | |
defaults: | |
run: | |
working-directory: apis/java/quarkus-legacy-oracle | |
outputs: | |
ROUTE: ${{ steps.deploy-and-expose.outputs.route }} | |
SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} | |
steps: | |
- name: Check for required secrets | |
uses: actions/github-script@v4 | |
with: | |
script: | | |
const secrets = { | |
OPENSHIFT_SERVER: `${{ secrets.OPENSHIFT_SERVER }}`, | |
OPENSHIFT_TOKEN: `${{ secrets.OPENSHIFT_TOKEN }}`, | |
}; | |
const GHCR = "ghcr.io"; | |
if (`${{ env.IMAGE_REGISTRY }}`.startsWith(GHCR)) { | |
core.info(`Image registry is ${GHCR} - no registry password required`); | |
} | |
else { | |
core.info("A registry password is required"); | |
secrets["IMAGE_REGISTRY_PASSWORD"] = `${{ secrets.IMAGE_REGISTRY_PASSWORD }}`; | |
} | |
const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => { | |
if (value.length === 0) { | |
core.error(`Secret "${name}" is not set`); | |
return true; | |
} | |
core.info(`✔️ Secret "${name}" is set`); | |
return false; | |
}); | |
if (missingSecrets.length > 0) { | |
core.setFailed(`❌ At least one required secret is not set in the repository. \n` + | |
"You can add it using:\n" + | |
"GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + | |
"GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" + | |
"Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); | |
} | |
else { | |
core.info(`✅ All the required secrets are set`); | |
} | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.IMAGE_REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build application | |
run: mvn clean package | |
- name: Build and push Application image | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
push: true | |
tags: | | |
"${{ env.IMAGE_REGISTRY }}/${{ env.APP_NAME }}:latest" | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
file: | | |
./apis/java/quarkus-legacy-oracle/.pipeline/openshift/Dockerfile | |
- uses: actions/checkout@v2 | |
- name: Deploy | |
run: | | |
set +e -ux | |
# Login to OpenShift and select project | |
oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} | |
oc tag -d ${{ env.APP_NAME }}:latest | |
oc tag ${{ env.IMAGE_REGISTRY }}/${{ env.APP_NAME }}:latest ${{ env.APP_NAME }}:latest | |
# Process and apply deployment template | |
oc process -f https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/main/apis/java/quarkus-legacy-oracle/.pipeline/openshift/openshift-deployment-config.yml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p JOB_NAME=${{ env.JOB_NAME }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_NO_ENV }}-${{env.TARGET_ENV}} -p TAG=${{ env.TAG }} -p MIN_REPLICAS=${{ env.MIN_REPLICAS }} -p MAX_REPLICAS=${{ env.MAX_REPLICAS }} -p MIN_CPU=${{ env.MIN_CPU }} -p MAX_CPU=${{ env.MAX_CPU }} -p MIN_MEM=${{ env.MIN_MEM }} -p MAX_MEM=${{ env.MAX_MEM }} \ | |
| oc create -f - | |
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/main/apis/java/quarkus-legacy-oracle/.pipeline/openshift/openshift-config-map.sh | bash /dev/stdin ${{ env.APP_NAME }} ${{ env.OIDC_AUTH_SERVER_URL }} ${{ env.OPENSHIFT_NAMESPACE_NO_ENV }}-${{env.TARGET_ENV}} ${{ env.DB_HOST }} ${{ env.DB_PORT }} ${{ env.FILE_LOG_LEVEL }} ${{ env.QUARKUS_DATASOURCE_JDBC_PASSWORD }} ${{ env.QUARKUS_DATASOURCE_JDBC_USERNAME }} ${{ env.SERVICE_NAME }} | |
# Start rollout (if necessary) and follow it | |
oc rollout latest dc/${{ env.APP_NAME }} 2> /dev/null \ | |
|| true && echo "Rollout in progress" | |
oc logs -f dc/${{ env.APP_NAME }} | |
# Get status, returns 0 if rollout is successful | |
oc rollout status dc/${{ env.APP_NAME }} |