Skip to content

Commit

Permalink
Merge branch 'master' into add-mod-settings-permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeTaylor committed Oct 21, 2024
2 parents 702507f + 1b3d1e9 commit e8245be
Show file tree
Hide file tree
Showing 103 changed files with 2,916 additions and 1,939 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/api-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
AWS_S3_ACCESS_KEY: ${{ secrets.INDEXDATA_S3_SECRET_ACCESS_KEY }}

on:
workflow_dispatch:
push:
branches: [ main, master ]
paths:
Expand All @@ -39,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.REF }}
submodules: recursive
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/api-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ env:
API_WARNINGS: false

on:
workflow_dispatch:
push:
paths:
- 'src/main/resources/openapi/**'
Expand All @@ -39,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare folio-tools
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/api-schema-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
API_EXCLUDES: 'example'

on:
workflow_dispatch:
push:
paths:
- 'src/main/resources/openapi/**'
Expand All @@ -29,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Prepare folio-tools
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/build-maven.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/k8s-deploy-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
name: k8s-deploy-latest

env:
K8S_NAMESPACE: 'harvester-dev'
K8S_DEPLOYMENT: 'mod-harvester-admin'
K8S_NAMESPACE: 'snapshot-dev'
K8S_DEPLOYMENT: 'mod-harvester-admin-dev'

on:
workflow_dispatch
Expand All @@ -18,9 +18,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Deploy latest to K8s
uses: actions-hub/kubectl@v1.21.2
uses: actions-hub/kubectl@v1.29.3
env:
KUBE_CONFIG: ${{ secrets.HARVESTER_DEV_SA_KUBECONFIG }}
KUBE_CONFIG: ${{ secrets.SNAPSHOT_DEV_SA_KUBECONFIG }}
with:
args:
-n ${{ env.K8S_NAMESPACE }} rollout restart deployment ${{ env.K8S_DEPLOYMENT }}
Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/mvn-dev-build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: mvn-dev-build-deploy

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

env:
PUBLISH_BRANCH: 'master'
OKAPI_URL: 'https://snapshot-dev-okapi.folio-dev.indexdata.com'
OKAPI_SECRET_USER: "${{ secrets.SNAPSHOT_DEV_OKAPI_USER }}"
OKAPI_SECRET_PASSWORD: "${{ secrets.SNAPSHOT_DEV_OKAPI_PASSWORD }}"
OK_SESSION: 'session1'

jobs:
mvn-dev-build-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
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@v4
with:
java-version: 17
distribution: 'temurin' # Alternative distribution options are available.

- name: Prepare okclient
run: git clone https://github.com/indexdata/okclient

- name: Ensure OK and FOLIO login
# So do not proceed with other workflow steps if not available.
run: |
source okclient/ok.sh
OK -S ${{ env.OK_SESSION }} \
-h ${{ env.OKAPI_URL }} \
-t "supertenant" \
-u ${{ env.OKAPI_SECRET_USER }} \
-p ${{ env.OKAPI_SECRET_PASSWORD }}
OK -S ${{ env.OK_SESSION }} -x
- 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@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

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

- name: Maven build
run: mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install org.jacoco:jacoco-maven-plugin:report

- name: SQ analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B 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 Index Data Docker Hub account
if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
uses: docker/login-action@v3
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@v6
with:
context: .
push: true
tags: indexdata/${{ env.MODULE_NAME }}:${{ env.MODULE_VERSION }},indexdata/${{ env.MODULE_NAME }}:latest

- name: Publish ModuleDescriptor to Okapi
if: ${{ env.CURRENT_BRANCH == env.PUBLISH_BRANCH }}
run: |
source okclient/ok.sh
echo "Do login ..."
OK -S ${{ env.OK_SESSION }} \
-h ${{ env.OKAPI_URL }} \
-t "supertenant" \
-u ${{ env.OKAPI_SECRET_USER }} \
-p ${{ env.OKAPI_SECRET_PASSWORD }}
echo "Post the MD and report the response status ..."
OK -S ${{ env.OK_SESSION }} _/proxy/modules \
-X post -f ${{ env.MODULE_DESCRIPTOR }}
declare -n NAMEREF_STATUS=${{ env.OK_SESSION }}_HTTPStatus
echo "Response status: $NAMEREF_STATUS"
echo "Do logout ..."
OK -S ${{ env.OK_SESSION }} -x
- name: Print module version to job summary
run: |
echo "#### Module Version: ${{ env.MODULE_VERSION }}" >> $GITHUB_STEP_SUMMARY
80 changes: 35 additions & 45 deletions .github/workflows/release-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ env:
FOLIO_MD_REGISTRY: 'https://registry.folio-dev.indexdata.com'
CONTAINER_REGISTRY: 'ghcr.io'
IMAGE_NAME: 'indexdata/mod-harvester-admin'
OK_SESSION: 'session1'

on:
push:
Expand All @@ -19,13 +20,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven
cache: 'maven'
- name: Gather some variables
run: |
echo "MODULE_NAME=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> $GITHUB_ENV
Expand All @@ -46,45 +47,34 @@ jobs:
fi
env:
MOD_DESCRIPTOR: './target/ModuleDescriptor.json'
- name: Login ModuleDescriptor registry
id: login-md-registry
# uses: indiesdev/[email protected]
uses: cyberman54/[email protected]
with:
url: "${{ env.FOLIO_MD_REGISTRY }}/authn/login"
method: "POST"
accept: 201
timeout: 5000
retries: 3
headers: |
{
"content-type": "application/json",
"x-okapi-tenant": "${{ secrets.FOLIO_REGISTRY_TENANT }}"
}
body: |
{
"username": "${{ secrets.FOLIO_REGISTRY_USERNAME }}",
"password": "${{ secrets.FOLIO_REGISTRY_PASSWORD }}"
}
- name: Get the MD registry login token
- name: Prepare okclient
run: git clone https://github.com/indexdata/okclient
- name: Ensure OK and FOLIO login
# So do not proceed with other workflow steps if not available.
run: |
echo "TOKEN_MD_REGISTRY=${{ fromJSON(steps.login-md-registry.outputs.response).headers['x-okapi-token'] }}" >> $GITHUB_ENV
source okclient/ok.sh
OK -S ${{ env.OK_SESSION }} \
-h ${{ env.FOLIO_MD_REGISTRY }} \
-t ${{ secrets.FOLIO_REGISTRY_TENANT }} \
-u ${{ secrets.FOLIO_REGISTRY_USERNAME }} \
-p ${{ secrets.FOLIO_REGISTRY_PASSWORD }}
OK -S ${{ env.OK_SESSION }} -x
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.ACTOR }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract docker metadata
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.CONTAINER_REGISTRY }}/${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.vendor=Index Data LLC
org.opencontainers.image.documentation=https://github.com/indexdata/localindices/tree/master/doc
- name: Build and publish Docker image
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
push: true
Expand All @@ -96,18 +86,18 @@ jobs:
with:
path: ${{ env.MODULE_DESCRIPTOR }}
- name: Publish ModuleDescriptor to MD registry
id: result-md-registry
# uses: indiesdev/[email protected]
uses: cyberman54/[email protected]
with:
url: "${{ env.FOLIO_MD_REGISTRY }}/_/proxy/modules"
method: "POST"
accept: 201
timeout: 5000
headers: |
{
"content-type": "application/json",
"x-okapi-tenant": "${{ secrets.FOLIO_REGISTRY_TENANT }}",
"x-okapi-token": "${{ env.TOKEN_MD_REGISTRY }}"
}
body: ${{ steps.moduleDescriptor.outputs.content }}
run: |
source okclient/ok.sh
echo "Do login ..."
OK -S ${{ env.OK_SESSION }} \
-h ${{ env.FOLIO_MD_REGISTRY }} \
-t ${{ secrets.FOLIO_REGISTRY_TENANT }} \
-u ${{ secrets.FOLIO_REGISTRY_USERNAME }} \
-p ${{ secrets.FOLIO_REGISTRY_PASSWORD }}
echo "Post the MD and report the response status ..."
OK -S ${{ env.OK_SESSION }} _/proxy/modules \
-X post -f ${{ env.MODULE_DESCRIPTOR }}
declare -n NAMEREF_STATUS=${{ env.OK_SESSION }}_HTTPStatus
echo "Response status: $NAMEREF_STATUS"
echo "Do logout ..."
OK -S ${{ env.OK_SESSION }} -x
Loading

0 comments on commit e8245be

Please sign in to comment.