Skip to content

Commit

Permalink
Merge branch 'deployment' into CIRCSTORE-452
Browse files Browse the repository at this point in the history
  • Loading branch information
nielserik authored Oct 3, 2023
2 parents 2884a2e + e7fde38 commit f2ea5fe
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 2 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/k8s-deploy-latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Very simple workflow to deploy the *latest* published container image with the 'latest' tag.
# This does not post updated module descriptors to okapi, update permissions or enable
# new versions of a module with the tenant. If that is needed, it should be done manually
# via the Okapi API.

name: k8s-deploy-latest

env:
K8S_NAMESPACE: 'orchid-dev'
K8S_DEPLOYMENT: 'mod-circulation-storage-dev'

on:
workflow_dispatch

jobs:
k8s-deploy-latest:

runs-on: ubuntu-latest
steps:
- name: Deploy latest to K8s
uses: actions-hub/[email protected]
env:
KUBE_CONFIG: ${{ secrets.ORCHID_DEV_SA_KUBECONFIG }}
with:
args:
-n ${{ env.K8S_NAMESPACE }} rollout restart deployment ${{ env.K8S_DEPLOYMENT }}

139 changes: 139 additions & 0 deletions .github/workflows/mvn-dev-build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: mvn-dev-build-deploy

on:
push:
pull_request:
types: [opened, synchronize, reopened]

env:
PUBLISH_BRANCH: 'deployment'
OKAPI_URL: 'https://orchid-dev-okapi.folio-dev.indexdata.com'
OKAPI_SECRET_USER: "${{ secrets.ORCHID_DEV_OKAPI_USER }}"
OKAPI_SECRET_PASSWORD: "${{ secrets.ORCHID_DEV_OKAPI_PASSWORD }}"

jobs:
mvn-dev-build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: recursive

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin' # Alternative distribution options are available.

- name: Gather some variables
run: |
echo "MODULE_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV
echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Set module version
run: |
echo "MODULE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)-${SHA_SHORT}" >> $GITHUB_ENV
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build and SQ analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=indexdata -Dsonar.projectKey=indexdata_${{ github.event.repository.name }}

- name: Update ModuleDescriptor Id
run: |
if test -f "$MOD_DESCRIPTOR"; then
echo "Found $MOD_DESCRIPTOR"
cat <<< $(jq '.id = "${{ env.MODULE_NAME}}-${{ env.MODULE_VERSION }}"' $MOD_DESCRIPTOR) > $MOD_DESCRIPTOR
echo "MODULE_DESCRIPTOR=$MOD_DESCRIPTOR" >> $GITHUB_ENV
else
echo "Could not find $MOD_DESCRIPTOR"
exit 1
fi
env:
MOD_DESCRIPTOR: './target/ModuleDescriptor.json'

- name: Read ModuleDescriptor
id: moduleDescriptor
uses: juliangruber/read-file-action@v1
with:
path: ${{ env.MODULE_DESCRIPTOR }}

- name: Login to dev Okapi instance
#if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
id: login-okapi
uses: cyberman54/curl@master
with:
url: "${{ env.OKAPI_URL }}/authn/login"
method: "POST"
accept: 201
timeout: 5000
retries: 3
headers: |
{
"content-type": "application/json",
"x-okapi-tenant": "supertenant"
}
body: |
{
"username": "${{ env.OKAPI_SECRET_USER }}",
"password": "${{ env.OKAPI_SECRET_PASSWORD }}"
}
- name: Login to Index Data Docker Hub account
if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and publish Docker image
if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: indexdata/${{ env.MODULE_NAME }}:${{ env.MODULE_VERSION }},indexdata/${{ env.MODULE_NAME }}:latest

- name: Get the Okapi login token
if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
run: |
echo "OKAPI_TOKEN=${{ fromJSON(steps.login-okapi.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV
- name: Publish ModuleDescriptor to Okapi
if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
id: result-okapi
# uses: indiesdev/[email protected]
uses: cyberman54/curl@master
with:
url: "${{ env.OKAPI_URL }}/_/proxy/modules"
method: "POST"
accept: 201
timeout: 10000
headers: |
{
"content-type": "application/json",
"x-okapi-tenant": "supertenant",
"x-okapi-token": "${{ env.OKAPI_TOKEN }}"
}
body: ${{ steps.moduleDescriptor.outputs.content }}

- name: Print module version to job summary
run: |
echo "#### Module Version: ${{ env.MODULE_VERSION }}" >> $GITHUB_STEP_SUMMARY
1 change: 1 addition & 0 deletions ramls/fixed-due-date-schedule.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"type": "string"
},
"schedules": {
"description": "tbd",
"id": "schedules",
"description": "List date ranges with a due date for each",
"type": "array",
Expand Down
3 changes: 2 additions & 1 deletion ramls/kv-configuration.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "tbd",
"type": "object",
"description": "Configuration entry",
"properties": {
Expand Down Expand Up @@ -49,4 +50,4 @@
"module",
"configName"
]
}
}
4 changes: 3 additions & 1 deletion ramls/kv-configurations.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "tbd",
"type": "object",
"description": "Collection of configuration entries",
"properties": {
"configs": {
"description": "tbd",
"id": "configurationData",
"description": "An array of configuration entries",
"type": "array",
Expand All @@ -25,4 +27,4 @@
"configs",
"totalRecords"
]
}
}
7 changes: 7 additions & 0 deletions ramls/loan-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"type": "boolean"
},
"loansPolicy": {
"description": "tbd",
"type": "object",
"description": "Settings for loans",
"additionalProperties": false,
Expand Down Expand Up @@ -47,6 +48,7 @@
"description": "Opening offset time period"
},
"fixedDueDateScheduleId": {
"description": "tbd",
"type": "string",
"description": "Fixed due date schedule (due date limit)"
},
Expand All @@ -63,6 +65,7 @@
"description": "Is item renewable"
},
"renewalsPolicy": {
"description": "tbd",
"type": "object",
"description": "Settings for renewals",
"properties": {
Expand Down Expand Up @@ -94,11 +97,13 @@
}
},
"requestManagement": {
"description": "tbd",
"type": "object",
"description": "Settings for various request types",
"additionalProperties": false,
"properties": {
"recalls": {
"description": "tbd",
"type": "object",
"description": "Settings for recall requests",
"additionalProperties": false,
Expand Down Expand Up @@ -131,6 +136,7 @@
}
},
"holds": {
"description": "tbd",
"type": "object",
"description": "Settings for hold requests",
"additionalProperties": false,
Expand All @@ -152,6 +158,7 @@
}
},
"pages": {
"description": "tbd",
"type": "object",
"description": "Settings for page requests",
"additionalProperties": false,
Expand Down
9 changes: 9 additions & 0 deletions ramls/patron-notice-policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"description": "Is this real time event"
},
"sendOptions": {
"description": "tbd",
"type": "object",
"description": "Notice sending options",
"additionalProperties": false,
Expand Down Expand Up @@ -93,11 +94,13 @@
]
},
"sendBy": {
"description": "tbd",
"type": "object",
"description": "Delay before the first attempt to send a notice",
"$ref": "interval.json"
},
"sendEvery": {
"description": "tbd",
"type": "object",
"description": "Interval between attempts to send a recurring notice",
"$ref": "interval.json"
Expand Down Expand Up @@ -156,6 +159,7 @@
"description": "Is this real time event"
},
"sendOptions": {
"description": "tbd",
"type": "object",
"description": "Notice sending options",
"additionalProperties": false,
Expand All @@ -180,11 +184,13 @@
]
},
"sendBy": {
"description": "tbd",
"type": "object",
"description": "Delay before the first attempt to send a notice",
"$ref": "interval.json"
},
"sendEvery": {
"description": "tbd",
"type": "object",
"description": "Interval between attempts to send a recurring notice",
"$ref": "interval.json"
Expand Down Expand Up @@ -243,6 +249,7 @@
"description": "Is this real time event"
},
"sendOptions": {
"description": "tbd",
"type": "object",
"description": "Notice sending options",
"additionalProperties": false,
Expand Down Expand Up @@ -270,11 +277,13 @@
]
},
"sendBy": {
"description": "tbd",
"type": "object",
"description": "Delay before the first attempt to send a notice",
"$ref": "interval.json"
},
"sendEvery": {
"description": "tbd",
"type": "object",
"description": "Interval between attempts to send a recurring notice",
"$ref": "interval.json"
Expand Down
1 change: 1 addition & 0 deletions ramls/period.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "tbd",
"type": "object",
"description": "Time interval defined by its duration",
"properties": {
Expand Down
2 changes: 2 additions & 0 deletions ramls/scheduled-notice.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "tbd",
"type": "object",
"description": "Scheduled patron notice",
"properties": {
Expand Down Expand Up @@ -56,6 +57,7 @@
]
},
"noticeConfig": {
"description": "tbd",
"type": "object",
"description": "Scheduled notice configuration",
"properties": {
Expand Down
1 change: 1 addition & 0 deletions ramls/staff-slip.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "tbd",
"type": "object",
"description": "Staff slip",
"properties": {
Expand Down

0 comments on commit f2ea5fe

Please sign in to comment.