Skip to content

Commit

Permalink
Add a simple deploy action
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Oct 9, 2024
1 parent 55674e3 commit d44228e
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Deploy

on:
push:
branches:
- "production"
paths-ignore:
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'
- '*.md'
- '*.adoc'
- '*.txt'
- '.all-contributorsrc'

concurrency:
group: deployment
cancel-in-progress: false

jobs:
deploy:

# if: github.repository == 'hibernate/hibernate-jira-sync'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 21

- name: Log in to OpenShift
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER_INFRA_PROD }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN_INFRA_PROD }}
namespace: ${{ secrets.OPENSHIFT_NAMESPACE_INFRA_PROD }}

- name: Create ImageStream
run: |
oc create imagestream hibernate-jira-sync || true
# https://docs.openshift.com/container-platform/4.14/openshift_images/using-imagestreams-with-kube-resources.html
oc set image-lookup hibernate-jira-sync
- name: Retrieve OpenShift Container Registry URL
id: oc-registry
run: |
echo -n "OC_REGISTRY_URL=" >> "$GITHUB_OUTPUT"
oc registry info >> "$GITHUB_OUTPUT"
- name: Log in to OpenShift Container Registry
uses: docker/login-action@v3
with:
registry: ${{ steps.oc-registry.outputs.OC_REGISTRY_URL }}
username: ignored
password: ${{ secrets.OPENSHIFT_TOKEN_INFRA_PROD }}
# Helm in particular needs semantic versions
# See https://github.com/helm/helm/issues/9342#issuecomment-775269042
# See the parts about pre-release versions in https://semver.org/#semantic-versioning-specification-semver
# Ideally we should use a "+" before the SHA, but that won't work with Quarkus
# See https://github.com/quarkusio/quarkus/blob/da1a782e04b01b2e165d65474163050d497340c1/extensions/container-image/spi/src/main/java/io/quarkus/container/spi/ImageReference.java#L60
- name: Generate app version
id: app-version
run: |
echo "VALUE=1.0.0-$(date -u '+%Y%m%d%H%M%S')-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: Build and push app container image
run: |
./mvnw clean package \
-Drevision="${{ steps.app-version.outputs.value }}" \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.push=true \
-Dquarkus.container-image.registry="$(oc registry info)" \
-Dquarkus.container-image.group="$(oc project --short)"
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>

<!-- Deploy -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-openshift</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-jib</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
Expand Down
25 changes: 25 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,28 @@ jira.project-group."hibernate".users.default-value=-1
%prod.jira.project-group."hibernate".projects.OGM.project-id=12346522
%prod.jira.project-group."hibernate".projects.OGM.project-key=OGM
%prod.jira.project-group."hibernate".projects.OGM.original-project-key=OGM
##############
# Deploy to OpenShift
#
quarkus.container-image.builder=jib
quarkus.openshift.part-of=hibernate-jira-sync
# Renew the SSL certificate automatically
# This requires an additional controller to run on the OpenShift cluster (in our case it does).
# See https://github.com/tnozicka/openshift-acme/#enabling-acme-certificates-for-your-object
quarkus.openshift.annotations."kubernetes.io/tls-acme"=true
quarkus.openshift.env.configmaps=hibernate-jira-sync-config
quarkus.openshift.env.secrets=hibernate-jira-sync-secrets
# Resource requirements
quarkus.openshift.resources.limits.cpu=2000m
quarkus.openshift.resources.requests.cpu=400m
quarkus.openshift.resources.limits.memory=2Gi
quarkus.openshift.resources.requests.memory=1Gi
quarkus.openshift.startup-probe.initial-delay=15S
quarkus.openshift.startup-probe.period=15S
quarkus.openshift.startup-probe.failure-threshold=48
# Declare the management port on the service
quarkus.openshift.ports."management".container-port=9000
quarkus.openshift.ports."management".host-port=90
# Don't use the version in (service) selectors,
# otherwise a rollback to an earlier version (due to failing startup) makes the service unavailable
quarkus.openshift.add-version-to-label-selectors=false

0 comments on commit d44228e

Please sign in to comment.